:root {
  --blue: #6BA8FF;
  --green: #7BD88F;
  --purple: #B892FF;
  --pink: #FFB6D9;
  --orange: #FFC970;
  --white: #FFFFFF;
  --page: #FFFFFF;
  --surface: #FFFFFF;
  --elevated: #FFFFFF;
  --card: #F7F8FA;
  --text: #2D2D2D;
  --muted: #777D87;
  --line: #E7EAF0;
  --hover: #EEF5FF;
  --selected: #EEF5FF;
  --topbar-bg: rgba(255, 255, 255, 0.94);
  --bar-border: rgba(231, 234, 240, 0.88);
  --event-mix-base: #FFFFFF;
  --notes: #5D6470;
  --chip-text: #4F5662;
  --empty-icon-bg: #EEF5FF;
  --danger-bg: #FFF0F5;
  --modal-backdrop: rgba(45, 45, 45, 0.22);
  --on-accent: #FFFFFF;
  --theme-choice-ring: rgba(255, 255, 255, 0.72);
  --shadow: 0 12px 34px rgba(29, 45, 68, 0.11);
  --soft-shadow: 0 8px 20px rgba(29, 45, 68, 0.08);
  --radius: 8px;
  --touch: 48px;
  --ad-banner-height: min(10dvh, 72px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101722;
  --surface: #172132;
  --elevated: #223047;
  --card: #1C2738;
  --text: #F4F7FB;
  --muted: #AAB4C3;
  --line: #334155;
  --hover: #263A55;
  --selected: #203A5B;
  --topbar-bg: rgba(16, 23, 34, 0.94);
  --bar-border: rgba(51, 65, 85, 0.84);
  --event-mix-base: #172132;
  --notes: #CAD2DF;
  --chip-text: #D7DEEA;
  --empty-icon-bg: #203A5B;
  --danger-bg: #3A1E2B;
  --modal-backdrop: rgba(0, 0, 0, 0.54);
  --theme-choice-ring: rgba(16, 23, 34, 0.78);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
  --soft-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

.notranslate {
  unicode-bidi: isolate;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.launch-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 20% 12%, rgba(107, 168, 255, 0.2), transparent 30%),
    radial-gradient(circle at 78% 86%, rgba(184, 146, 255, 0.24), transparent 33%),
    #FFFFFF;
  opacity: 1;
  transition: opacity 320ms ease, transform 320ms ease;
}

:root[data-theme="dark"] .launch-screen {
  background:
    radial-gradient(circle at 20% 12%, rgba(107, 168, 255, 0.18), transparent 30%),
    radial-gradient(circle at 78% 86%, rgba(184, 146, 255, 0.18), transparent 33%),
    var(--page);
}

.launch-screen.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
}

.launch-logo {
  width: min(46vw, 188px);
  height: min(46vw, 188px);
  border-radius: 34px;
  object-fit: cover;
  box-shadow: 0 24px 56px rgba(61, 77, 130, 0.22);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  position: relative;
  display: flex;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  overflow-x: hidden;
  background: var(--page);
}

.screen {
  display: flex;
  width: 100%;
  min-height: 100dvh;
  flex-direction: column;
  background: var(--page);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  flex: 1;
  padding: 14px 16px 104px;
}

body[data-has-ad="true"] .content {
  padding-bottom: calc(104px + var(--ad-banner-height));
}

.topbar,
.screen-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--bar-border);
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: var(--soft-shadow);
}

.brand-title,
.bar-title {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.1;
}

.brand-title,
.brand-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle,
.bar-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.bar-copy {
  min-width: 0;
  flex: 1;
}

.screen-bar {
  justify-content: flex-start;
}

.screen-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.icon-button,
.menu-button,
.settings-color-choice,
.settings-fab-position-choice,
.chip-button,
.primary-button,
.secondary-button,
.danger-button,
.save-button,
.fab {
  display: inline-flex;
  min-height: var(--touch);
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.icon-button:active,
.menu-button:active,
.settings-color-choice:active,
.settings-fab-position-choice:active,
.view-switch-button:active,
.chip-button:active,
.primary-button:active,
.secondary-button:active,
.danger-button:active,
.save-button:active,
.fab:active,
.day-cell:active,
.week-day-card:active,
.type-tile:active,
.event-card:active {
  transform: scale(0.98);
}

.icon-button {
  width: var(--touch);
  height: var(--touch);
  flex: 0 0 auto;
  border-radius: 16px;
  background: var(--card);
}

.icon-button:hover,
.menu-button:hover,
.secondary-button:hover {
  background: var(--hover);
}

.menu-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 15px;
  background: var(--card);
  font-size: 22px;
  box-shadow: 0 6px 14px rgba(29, 45, 68, 0.05);
}

.menu-button {
  color: var(--blue);
}

.settings-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 45;
  display: grid;
  width: min(300px, calc(100vw - 28px));
  max-height: calc(100dvh - max(102px, env(safe-area-inset-top) + 88px));
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-menu-row {
  display: grid;
  min-height: 48px;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 15px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 850;
  text-align: left;
}

.settings-menu-row:hover {
  background: var(--hover);
}

.settings-row-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 13px;
  background: var(--surface);
  color: var(--blue);
  font-size: 13px;
  font-weight: 950;
  box-shadow: inset 0 0 0 1px var(--line);
}

.settings-row-icon .icon {
  width: 21px;
  height: 21px;
}

.settings-menu-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 15px;
  background: var(--card);
}

.settings-menu-group p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.settings-color-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.settings-color-choice {
  width: 100%;
  min-height: 38px;
  border: 3px solid var(--surface);
  border-radius: 14px;
  background: var(--theme-choice);
  box-shadow: 0 7px 14px rgba(29, 45, 68, 0.12);
}

.settings-color-choice.is-selected {
  outline: 3px solid color-mix(in srgb, var(--theme-choice) 54%, var(--text));
  outline-offset: 2px;
}

.settings-fab-position-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.settings-fab-position-choice {
  display: grid;
  min-height: 58px;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  text-align: left;
}

.settings-fab-position-choice.is-selected {
  border-color: color-mix(in srgb, var(--blue) 62%, var(--line));
  background: color-mix(in srgb, var(--blue) 13%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 44%, transparent);
}

.fab-position-preview {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
}

.fab-position-preview span {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 0 3px 8px color-mix(in srgb, var(--blue) 42%, transparent);
}

.fab-position-preview.is-bottom-right span {
  right: 4px;
  bottom: 4px;
}

.fab-position-preview.is-bottom-left span {
  bottom: 4px;
  left: 4px;
}

.fab-position-preview.is-top-right span {
  top: 4px;
  right: 4px;
}

.fab-position-preview.is-top-left span {
  top: 4px;
  left: 4px;
}

.icon {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.calendar-panel,
.month-panel {
  padding: 14px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--soft-shadow);
  touch-action: pan-y;
}

.calendar-toolbar,
.month-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.calendar-title,
.month-title {
  margin: 0;
  font-size: 24px;
  font-weight: 850;
  line-height: 1.1;
}

.month-controls {
  display: flex;
  gap: 8px;
}

.view-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
  padding: 5px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.view-switch-button {
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 850;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.view-switch-button.is-selected {
  background: var(--blue);
  color: var(--on-accent);
  box-shadow: 0 8px 16px rgba(107, 168, 255, 0.24);
}

.weekdays,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.month-grid {
  gap: 6px;
  aspect-ratio: 1 / 1;
  grid-template-rows: repeat(6, minmax(0, 1fr));
}

.calendar-panel.is-with-agenda {
  padding-bottom: 12px;
}

.calendar-panel.is-with-agenda .day-cell {
  min-height: 0;
}

.calendar-panel.is-with-agenda .day-number {
  width: 26px;
  height: 26px;
  font-size: 13px;
}

.week-strip {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.week-day-card {
  display: flex;
  width: 100%;
  min-height: 92px;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 6px 16px rgba(29, 45, 68, 0.06);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.week-day-card.is-selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(107, 168, 255, 0.76), 0 8px 18px rgba(107, 168, 255, 0.16);
}

.week-day-card.is-today .week-day-number {
  background: var(--blue);
  color: var(--on-accent);
}

.week-day-head {
  display: flex;
  width: 58px;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 16px;
  background: var(--card);
}

.week-day-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.week-day-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 900;
}

.week-day-events {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.week-event {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--event-color) 18%, var(--event-mix-base));
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
}

.week-event span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-empty {
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.day-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.day-view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(29, 45, 68, 0.06);
}

.day-view-title {
  margin: 0;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.14;
}

.day-view-events {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-view-empty {
  display: flex;
  min-height: 360px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px 14px;
  border-radius: 22px;
  background: var(--surface);
  text-align: center;
  box-shadow: 0 6px 16px rgba(29, 45, 68, 0.06);
}

.day-cell {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 5px;
  align-items: stretch;
  padding: 7px 5px 5px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 10px rgba(29, 45, 68, 0.04);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.day-cell:hover {
  border-color: rgba(107, 168, 255, 0.5);
}

.day-cell.is-muted {
  color: #A4AAB4;
  background: color-mix(in srgb, var(--surface) 58%, transparent);
}

.day-cell.is-today {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue), 0 5px 12px rgba(107, 168, 255, 0.16);
}

.day-cell.is-selected {
  border-color: var(--blue);
  background: var(--selected);
  box-shadow: inset 0 0 0 1px var(--blue), 0 8px 18px rgba(107, 168, 255, 0.16);
}

.day-cell.has-events {
  background: var(--surface);
}

.day-cell.is-selected.has-events {
  background: var(--selected);
}

.day-number {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 850;
}

.is-today .day-number {
  background: var(--blue);
  color: var(--on-accent);
}

.is-selected .day-number {
  background: var(--blue);
  color: var(--on-accent);
}

.day-events {
  display: flex;
  min-width: 0;
  overflow: hidden;
  flex-direction: column;
  gap: 4px;
}

.calendar-panel.is-with-agenda .calendar-event {
  width: 100%;
  max-width: 18px;
  min-height: 8px;
  padding: 0;
}

.calendar-panel.is-with-agenda .calendar-event span:last-child {
  display: none;
}

.calendar-panel.is-with-agenda .mini-dot {
  width: 8px;
  height: 8px;
}

.calendar-event {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  padding: 3px 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--event-color) 18%, var(--event-mix-base));
  color: var(--text);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.calendar-event span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--event-color);
}

.more-events {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.fab {
  position: fixed;
  z-index: 30;
  width: 62px;
  height: 62px;
  border-radius: 22px;
  background: var(--blue);
  color: var(--on-accent);
  box-shadow: 0 18px 34px rgba(107, 168, 255, 0.38);
}

.fab.is-bottom-right {
  right: max(18px, calc((100vw - 480px) / 2 + 18px));
  bottom: max(20px, env(safe-area-inset-bottom));
}

.fab.is-bottom-left {
  bottom: max(20px, env(safe-area-inset-bottom));
  left: max(18px, calc((100vw - 480px) / 2 + 18px));
}

body[data-has-ad="true"] .fab.is-bottom-right,
body[data-has-ad="true"] .fab.is-bottom-left {
  bottom: calc(var(--ad-banner-height) + 16px);
}

.fab.is-top-right {
  top: max(94px, calc(env(safe-area-inset-top) + 78px));
  right: max(18px, calc((100vw - 480px) / 2 + 18px));
}

.fab.is-top-left {
  top: max(94px, calc(env(safe-area-inset-top) + 78px));
  left: max(18px, calc((100vw - 480px) / 2 + 18px));
}

.fab .icon {
  width: 28px;
  height: 28px;
}

.ad-banner {
  position: fixed;
  right: max(0px, calc((100vw - 480px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 480px) / 2));
  z-index: 24;
  display: flex;
  max-width: 480px;
  height: var(--ad-banner-height);
  margin: 0 auto;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--bar-border);
  background: color-mix(in srgb, var(--surface) 92%, var(--blue));
  box-shadow: 0 -10px 28px rgba(29, 45, 68, 0.08);
}

.ad-banner-inner {
  display: flex;
  width: 100%;
  min-height: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed color-mix(in srgb, var(--blue) 42%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--card) 74%, transparent);
  color: var(--muted);
  font-size: clamp(10px, 2.2dvh, 13px);
  font-weight: 850;
  line-height: 1;
  text-align: center;
}

.ad-banner-inner span {
  color: var(--blue);
  font-weight: 950;
  text-transform: uppercase;
}

.ad-banner-inner strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.selected-day-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.selected-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}

.selected-day-copy {
  min-width: 0;
}

.selected-day-title {
  margin: 2px 0 0;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.15;
}

.selected-day-count {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.selected-day-events {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.selected-day-empty {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--soft-shadow);
}

.empty-title.compact {
  font-size: 20px;
}

.event-card {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 96px;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 0;
  border-radius: 20px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--soft-shadow);
  -webkit-tap-highlight-color: transparent;
}

.event-card::before {
  content: "";
  width: 8px;
  border-radius: 999px;
  background: var(--event-color);
}

.event-card-body {
  min-width: 0;
  flex: 1;
}

.event-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.event-type-pill {
  display: inline-flex;
  max-width: 62%;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 850;
  box-shadow: 0 4px 12px rgba(29, 45, 68, 0.05);
}

.event-type-pill .icon {
  width: 18px;
  height: 18px;
  color: var(--event-color);
}

.event-type-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
  text-align: right;
}

.notes-preview {
  display: -webkit-box;
  overflow: hidden;
  color: var(--notes);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-state {
  display: grid;
  min-height: 58dvh;
  place-items: center;
  padding: 24px 10px;
  text-align: center;
}

.empty-state-inner {
  display: flex;
  width: 100%;
  max-width: 330px;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.empty-icon {
  display: grid;
  width: 84px;
  height: 84px;
  place-items: center;
  border-radius: 26px;
  background: var(--empty-icon-bg);
  color: var(--blue);
}

.empty-icon .icon {
  width: 38px;
  height: 38px;
}

.empty-title {
  margin: 0;
  font-size: 23px;
  font-weight: 850;
}

.empty-copy {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.primary-button,
.secondary-button,
.danger-button {
  width: 100%;
  gap: 9px;
  padding: 0 18px;
  border-radius: 18px;
  font-size: 16px;
  font-weight: 850;
}

.primary-button {
  background: var(--blue);
  color: var(--on-accent);
  box-shadow: 0 14px 26px rgba(107, 168, 255, 0.28);
}

.secondary-button {
  background: var(--card);
}

.danger-button {
  background: var(--danger-bg);
  color: #D43F72;
}

.form-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  padding: 16px 16px 116px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 850;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.type-tile {
  position: relative;
  display: flex;
  min-height: 132px;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  overflow: hidden;
  padding: 14px;
  border: 2px solid transparent;
  border-radius: 20px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--type-color) 24%, var(--event-mix-base)), color-mix(in srgb, var(--type-color) 10%, var(--surface))),
    var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 8px 18px rgba(29, 45, 68, 0.07);
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.type-tile.is-selected {
  border-color: var(--type-color);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--type-color) 34%, var(--event-mix-base)), color-mix(in srgb, var(--type-color) 14%, var(--surface))),
    var(--surface);
}

:root[data-theme="dark"] .type-tile {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--type-color) 14%, #D8D0C1), #D0C8BA),
    #D0C8BA;
  color: #2D2D2D;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

:root[data-theme="dark"] .type-tile.is-selected {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--type-color) 21%, #DED6C8), #D8D0C2),
    #D8D0C2;
}

.type-artwork {
  position: absolute;
  right: -18px;
  bottom: -16px;
  z-index: -1;
  width: 138px;
  height: 92px;
  color: var(--type-color);
  opacity: 0.34;
  pointer-events: none;
  transform: rotate(-3deg);
}

.type-artwork.is-photo {
  right: -24px;
  bottom: -20px;
  width: 152px;
  height: 104px;
  opacity: 0.2;
  overflow: hidden;
  border-radius: 22px;
  transform: rotate(-4deg) scale(1.08);
}

.type-artwork-svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.type-artwork-image {
  display: block;
  width: 100%;
  height: 130%;
  object-fit: cover;
  object-position: center top;
}

.type-tile.is-selected .type-artwork {
  opacity: 0.48;
  transform: rotate(-3deg) scale(1.04);
}

.type-tile.is-selected .type-artwork.is-photo {
  opacity: 0.3;
  transform: rotate(-4deg) scale(1.12);
}

.type-icon-box {
  position: relative;
  z-index: 1;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 15px;
  background: color-mix(in srgb, var(--surface) 82%, var(--type-color));
  color: var(--type-color);
  box-shadow: 0 6px 14px rgba(29, 45, 68, 0.08);
}

.type-icon-box.has-image {
  width: 100%;
  height: 78px;
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
  background: transparent;
}

:root[data-theme="dark"] .type-icon-box {
  background: color-mix(in srgb, #D0C8BA 84%, var(--type-color));
}

:root[data-theme="dark"] .type-icon-box.has-image {
  background: transparent;
}

.type-icon-box .icon {
  width: 25px;
  height: 25px;
  stroke-width: 2.4;
}

.training-type-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  background: rgba(232, 220, 203, 0.5);
}

:root[data-theme="dark"] .training-type-image {
  background: rgba(212, 196, 174, 0.5);
}

.training-type-image-source {
  display: block;
  width: 125%;
  height: 125%;
  object-fit: contain;
  object-position: center;
}

.event-type-pill .training-type-image {
  width: 26px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 8px;
}

.event-type-pill .training-type-image-source {
  width: 124%;
  height: 124%;
}

.detail-hero-icon .training-type-image {
  width: 52px;
  height: 46px;
  border-radius: 14px;
}

.detail-hero-icon .training-type-image-source {
  width: 118%;
  height: 118%;
}

.type-title {
  position: relative;
  z-index: 1;
  max-width: 100%;
  font-size: 16px;
  font-weight: 850;
  line-height: 1.18;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-grid .full {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.input,
.textarea {
  width: 100%;
  min-height: var(--touch);
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input {
  padding: 0 14px;
}

.textarea {
  min-height: 126px;
  padding: 14px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus,
.textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(107, 168, 255, 0.14);
}

.color-row,
.reminder-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-chip {
  width: 46px;
  height: 46px;
  border: 3px solid var(--surface);
  border-radius: 16px;
  background: var(--chip-color);
  box-shadow: 0 7px 14px rgba(29, 45, 68, 0.12);
}

.color-chip.is-selected {
  outline: 3px solid color-mix(in srgb, var(--chip-color) 54%, var(--text));
  outline-offset: 2px;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-picker {
  width: 64px;
  height: 52px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.color-value {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.chip-button {
  flex: 1 1 calc(50% - 10px);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--chip-text);
  font-size: 14px;
  font-weight: 850;
}

.chip-button.is-selected {
  border-color: var(--blue);
  background: var(--selected);
  color: var(--blue);
}

.save-bar,
.details-actions {
  position: fixed;
  right: max(0px, calc((100vw - 480px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 480px) / 2));
  z-index: 25;
  display: flex;
  max-width: 480px;
  gap: 10px;
  margin: 0 auto;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--bar-border);
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
}

.save-button {
  width: 100%;
  gap: 9px;
  padding: 0 18px;
  border-radius: 20px;
  background: var(--blue);
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 900;
  box-shadow: 0 16px 28px color-mix(in srgb, var(--blue) 34%, transparent);
}

.sync-panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.firebase-account-card,
.utility-card,
.calendar-export-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--soft-shadow);
}

.firebase-account-card.is-signed-in {
  border-color: color-mix(in srgb, var(--green) 46%, var(--line));
}

.utility-card.is-ready {
  border-color: color-mix(in srgb, var(--green) 46%, var(--line));
}

.firebase-account-head,
.utility-card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.firebase-account-icon,
.utility-card-icon {
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 18px;
  background: var(--card);
  color: var(--blue);
}

.firebase-account-icon .icon,
.utility-card-icon .icon {
  width: 26px;
  height: 26px;
}

.firebase-account-copy,
.utility-card-copy {
  min-width: 0;
  flex: 1;
}

.firebase-account-copy h3,
.utility-card-copy h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.15;
}

.firebase-account-copy p,
.firebase-account-copy span,
.utility-card-copy p {
  display: block;
  overflow: hidden;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.firebase-account-copy .firebase-sync-meta {
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  opacity: 0.72;
}

.utility-card-copy p {
  line-height: 1.38;
  white-space: normal;
}

.firebase-debug {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--card) 82%, transparent);
}

.firebase-debug span {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  white-space: normal;
}

.firebase-account-actions {
  display: grid;
  gap: 10px;
}

.firebase-account-button,
.utility-card-button {
  min-height: 50px;
}

.firebase-data-note {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.utility-card-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.app-version-footer {
  margin: 0;
  padding: 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  opacity: 0.66;
}

.privacy-link {
  display: inline-flex;
  justify-content: center;
  margin: auto 0 0;
  padding: 8px 4px 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

.detail-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 18px;
  border-radius: 24px;
  background: color-mix(in srgb, var(--event-color) 23%, var(--event-mix-base));
  box-shadow: var(--soft-shadow);
}

.detail-hero-icon {
  display: grid;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 22px;
  background: var(--surface);
  color: var(--event-color);
  box-shadow: 0 7px 16px rgba(29, 45, 68, 0.09);
}

.detail-hero-icon .icon {
  width: 34px;
  height: 34px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--notes);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-title {
  margin: 0;
  font-size: 27px;
  font-weight: 900;
  line-height: 1.08;
}

.detail-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--soft-shadow);
}

.calendar-export-card {
  margin-top: 14px;
}

.calendar-export-copy {
  margin: 0;
  color: var(--notes);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;
}

.calendar-export-actions {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.detail-value {
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.color-swatch-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.detail-swatch {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: var(--event-color);
  box-shadow: inset 0 0 0 2px var(--theme-choice-ring);
}

.details-actions .secondary-button,
.details-actions .danger-button {
  flex: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: var(--modal-backdrop);
}

.confirm-sheet {
  width: 100%;
  max-width: 448px;
  padding: 18px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.confirm-sheet h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 900;
}

.confirm-sheet p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toast {
  position: fixed;
  right: max(16px, calc((100vw - 480px) / 2 + 16px));
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px));
  z-index: 80;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 16px;
  background: #2D2D2D;
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

body[data-has-ad="true"] .toast {
  bottom: calc(var(--ad-banner-height) + max(14px, env(safe-area-inset-bottom)));
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 380px) {
  .content,
  .form-content {
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar,
  .screen-bar {
    padding-right: 12px;
    padding-left: 12px;
  }

  .calendar-panel,
  .month-panel {
    padding: 10px;
    border-radius: 20px;
  }

  .day-cell {
    min-height: 0;
    padding: 5px 4px;
    border-radius: 14px;
  }

  .calendar-event {
    padding: 3px 4px;
    font-size: 9px;
  }

  .type-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .calendar-title {
    font-size: 21px;
  }

  .week-day-card {
    min-height: 86px;
    padding: 10px;
  }

  .week-day-head {
    width: 52px;
  }

  .event-card-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .event-type-pill {
    max-width: 100%;
  }

  .event-time {
    text-align: left;
  }
}

@supports not (background: color-mix(in srgb, #000 50%, #fff)) {
  .calendar-event,
  .type-tile,
  .type-tile.is-selected,
  .detail-hero {
    background: var(--card);
  }
}
