:root {
  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  --bg: #f5f2ea;
  --page: #faf8f2;
  --card: rgba(255, 255, 255, 0.86);
  --card-strong: #ffffff;
  --line: rgba(33, 41, 52, 0.12);
  --line-strong: rgba(33, 41, 52, 0.18);
  --text: #1f2933;
  --muted: #667085;
  --accent: #16697a;
  --accent-soft: rgba(22, 105, 122, 0.12);
  --danger: #bf4342;
  --shadow: 0 16px 40px rgba(20, 30, 43, 0.08);
  --radius: 24px;
  --radius-sm: 16px;
  --gap: 20px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d141b;
  --page: #101923;
  --card: rgba(17, 24, 34, 0.84);
  --card-strong: #141d28;
  --line: rgba(236, 242, 248, 0.1);
  --line-strong: rgba(236, 242, 248, 0.16);
  --text: #edf2f7;
  --muted: #99a7b8;
  --accent: #6cc8d5;
  --accent-soft: rgba(108, 200, 213, 0.14);
  --danger: #ff8b7f;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(22, 105, 122, 0.08), transparent 34%),
    linear-gradient(180deg, #fbfaf6 0%, var(--bg) 100%);
}

:root[data-theme="dark"] html,
:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(108, 200, 213, 0.12), transparent 34%),
    linear-gradient(180deg, #081018 0%, var(--bg) 100%);
}

body[data-mode="mcp"] {
  background: transparent;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

code {
  font-family: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, monospace;
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

body[data-mode="mcp"] .page-shell {
  width: 100%;
  padding: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 6px 4px 22px;
}

body[data-mode="mcp"] .page-head {
  display: none;
}

.page-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-head h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1;
}

.page-copy {
  margin: 0;
  max-width: 58ch;
  color: var(--muted);
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.page-chip {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

:root[data-theme="dark"] .page-chip,
:root[data-theme="dark"] .ghost-button,
:root[data-theme="dark"] .stat,
:root[data-theme="dark"] .event-item,
:root[data-theme="dark"] .detail-card,
:root[data-theme="dark"] .day-cell,
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field textarea {
  background: rgba(14, 22, 31, 0.84);
}

.widget-frame {
  border-radius: 28px;
}

.calendar-app {
  display: grid;
  gap: var(--gap);
}

.hero,
.panel,
.dialog-body {
  background: var(--card);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

body[data-mode="mcp"] .hero,
body[data-mode="mcp"] .panel,
body[data-mode="mcp"] .dialog-body {
  box-shadow: none;
}

.hero {
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -12% -45% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(22, 105, 122, 0.14), transparent 68%);
  pointer-events: none;
}

.hero-top,
.hero-bottom,
.toolbar,
.panel-head,
.event-actions,
.detail-actions,
.dialog-actions,
.subscription-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.hero-top,
.hero-bottom,
.panel-head {
  justify-content: space-between;
}

.hero-top {
  margin-bottom: 14px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.hero-copy {
  max-width: 64ch;
}

.hero-copy h2 {
  margin: 0 0 8px;
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.05;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
}

.toolbar {
  flex-wrap: wrap;
}

.button,
.ghost-button,
.danger-button,
.day-cell {
  border-radius: 14px;
  border: 1px solid transparent;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  font-weight: 600;
}

.button {
  background: var(--accent);
  color: #f7fbfc;
  box-shadow: 0 8px 20px rgba(22, 105, 122, 0.18);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  border-color: var(--line);
}

.danger-button {
  background: rgba(191, 67, 66, 0.08);
  color: var(--danger);
  border-color: rgba(191, 67, 66, 0.14);
}

.button:hover,
.ghost-button:hover,
.danger-button:hover,
.day-cell:hover,
.event-item:hover {
  transform: translateY(-1px);
}

.button:disabled,
.ghost-button:disabled,
.danger-button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.52);
}

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

.stat-value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.95fr);
  gap: var(--gap);
}

.panel {
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 17px;
}

.panel-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.agenda-list,
.upcoming-list,
.calendar-grid {
  margin-top: 16px;
}

.agenda-list,
.upcoming-list {
  display: grid;
  gap: 12px;
}

.event-item {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.68);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.event-item.is-active {
  border-color: rgba(22, 105, 122, 0.36);
  background: rgba(22, 105, 122, 0.08);
}

.event-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.event-title {
  margin: 0 0 4px;
  font-size: 16px;
}

.event-time,
.event-location,
.event-note,
.hint,
.empty {
  color: var(--muted);
  font-size: 14px;
}

.hint,
.empty {
  margin: 16px 0 0;
}

.detail-card {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
}

.detail-time {
  font-size: 18px;
  font-weight: 700;
}

.detail-actions {
  flex-wrap: wrap;
}

.subscription {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.subscription-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.subscription-links {
  flex-wrap: wrap;
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
}

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

.weekday,
.day-cell {
  padding: 12px 10px;
  text-align: left;
}

.weekday {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.day-cell {
  min-height: 88px;
  display: grid;
  align-content: space-between;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
}

.day-cell.is-muted {
  opacity: 0.5;
}

.day-cell.is-today {
  border-color: rgba(22, 105, 122, 0.42);
}

.day-cell.is-selected {
  background: rgba(22, 105, 122, 0.12);
  border-color: rgba(22, 105, 122, 0.35);
}

.day-number {
  font-weight: 700;
}

.day-count {
  justify-self: start;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(22, 105, 122, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.dialog {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(560px, calc(100vw - 24px));
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.26);
}

.dialog-body {
  padding: 20px;
}

.dialog-body h3 {
  margin: 0 0 14px;
  font-size: 20px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

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

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(22, 105, 122, 0.42);
  box-shadow: 0 0 0 4px rgba(22, 105, 122, 0.1);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

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

.toast {
  position: sticky;
  top: 12px;
  z-index: 20;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(191, 67, 66, 0.16);
  background: rgba(191, 67, 66, 0.08);
  color: #7c2d12;
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex: none;
}

@media (max-width: 920px) {
  .page-head,
  .layout,
  .hero-top,
  .hero-bottom {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    padding: 14px 0 24px;
  }

  .hero,
  .panel,
  .dialog-body {
    border-radius: 22px;
  }

  .calendar-grid {
    gap: 8px;
  }

  .day-cell {
    min-height: 74px;
    padding: 10px 8px;
  }

  .split {
    grid-template-columns: 1fr;
  }
}
