:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --surface-soft: #f7f8fc;
  --surface-tint: #f0f2ff;
  --border: rgba(43, 55, 85, 0.11);
  --border-strong: rgba(43, 55, 85, 0.18);
  --text: #202638;
  --muted: #667085;
  --subtle: #8b95a7;
  --accent: #6474df;
  --accent-strong: #4f5fd0;
  --accent-soft: #eef0ff;
  --accent-glow: rgba(100, 116, 223, 0.18);
  --success: #258468;
  --success-soft: rgba(37, 132, 104, 0.09);
  --danger: #c84f5b;
  --danger-soft: rgba(200, 79, 91, 0.09);
  --warning: #a56c16;
  --warning-soft: #fff8e9;
  --shadow: 0 24px 70px rgba(61, 73, 104, 0.12);
  --shadow-soft: 0 12px 36px rgba(61, 73, 104, 0.08);
  --radius-xl: 28px;
  --radius-lg: 21px;
  --radius-md: 15px;
  --radius-sm: 11px;
  --max-width: 1220px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 0%, rgba(130, 155, 235, 0.2), transparent 32%),
    radial-gradient(circle at 92% 9%, rgba(196, 167, 238, 0.18), transparent 34%),
    linear-gradient(180deg, #f8f9fd 0%, var(--bg) 44%, #f3f6fb 100%);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  line-height: 1.5;
}

button, input, textarea { font: inherit; }
button, label, input[type="checkbox"], input[type="radio"] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
img { max-width: 100%; }

:focus-visible {
  outline: 3px solid rgba(100, 116, 223, 0.55);
  outline-offset: 3px;
}

.is-hidden { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(125px);
  opacity: 0.15;
  pointer-events: none;
}
.ambient-one { top: -19rem; left: -13rem; background: #8ea8ee; }
.ambient-two { top: 7rem; right: -21rem; background: #c7a9eb; }

.site-header {
  width: min(calc(100% - 40px), var(--max-width));
  min-height: 82px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.08rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #dfe5ff, #8999ed 58%, #bba0e8);
  color: #222940;
  font-family: "Instrument Serif", serif;
  font-size: 1.42rem;
  box-shadow: 0 10px 26px rgba(100, 116, 223, 0.2);
}

.brand-accent { color: var(--accent); }

.account-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.user-avatar-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  flex: none;
}

.user-avatar,
.user-avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  box-shadow: 0 5px 16px rgba(61, 73, 104, 0.12);
}

.user-avatar {
  display: block;
  object-fit: cover;
  background: var(--surface-strong);
}

.user-avatar-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #dfe5ff, #eee7ff);
  color: var(--accent-strong);
  font-weight: 700;
  text-transform: uppercase;
}

.app-shell {
  width: min(calc(100% - 40px), var(--max-width));
  margin: 0 auto;
  padding: 22px 0 88px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 24px;
  align-items: start;
}

.composer-card,
.events-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.tab {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: transparent;
  color: var(--subtle);
  cursor: pointer;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.tab:hover {
  color: var(--text);
  background: rgba(100, 116, 223, 0.05);
}

.tab.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(100, 116, 223, 0.07);
}

.tab:active { transform: scale(0.98); }

.panel-wrap { padding: clamp(22px, 4vw, 34px); }
.panel { min-height: 530px; }

.field { margin: 0 0 24px; }

.field label,
.field legend {
  display: block;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.field legend { padding: 0; }
fieldset { min-width: 0; padding: 0; border: 0; }

input[type="text"],
input[type="date"],
input[type="time"],
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  padding: 15px 16px;
  box-shadow: 0 1px 2px rgba(42, 51, 78, 0.02);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:hover,
textarea:hover { border-color: var(--border-strong); }

input:focus,
textarea:focus {
  border-color: rgba(100, 116, 223, 0.66);
  box-shadow: 0 0 0 4px rgba(100, 116, 223, 0.11);
  background: #fff;
  outline: 0;
}

textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

::placeholder { color: #9ba3b2; }

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

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  color: var(--subtle);
  font-size: 0.75rem;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice {
  position: relative;
  margin: 0 !important;
  cursor: pointer;
}

.choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.choice span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
  transition: all 150ms ease;
}

.choice input:focus-visible + span {
  outline: 3px solid rgba(100, 116, 223, 0.5);
  outline-offset: 2px;
}

.choice input:checked + span {
  color: var(--accent-strong);
  border-color: rgba(100, 116, 223, 0.28);
  background: var(--accent-soft);
}

.choice:hover span { border-color: var(--border-strong); }

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.87rem;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0) scale(0.98); }
.button:disabled { opacity: 0.48; cursor: not-allowed; }

.button-primary {
  background: linear-gradient(135deg, #7f8ee8, #5d6ed7);
  color: #fff;
  box-shadow: 0 13px 30px rgba(100, 116, 223, 0.22);
}

.button-primary:hover:not(:disabled) {
  box-shadow: 0 16px 34px rgba(100, 116, 223, 0.28);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
}

.button-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.button-full { width: 100%; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--subtle);
  font-size: 0.74rem;
  margin: 22px 0;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}

.drop-zone {
  display: grid !important;
  place-items: center;
  text-align: center;
  min-height: 210px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: rgba(247, 248, 252, 0.82);
  cursor: pointer;
  padding: 24px;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: rgba(100, 116, 223, 0.5);
  background: var(--accent-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: #fff;
  color: var(--accent);
  font-size: 1.25rem;
  margin-bottom: 12px;
  box-shadow: var(--shadow-soft);
}

.drop-title { color: var(--text); font-weight: 700; }
.drop-description { color: var(--subtle); font-size: 0.8rem; margin-top: 5px; }

.image-preview {
  width: min(100%, 420px);
  max-height: 280px;
  object-fit: contain;
  border-radius: var(--radius-md);
  margin-top: 16px;
  border: 1px solid var(--border);
  background: #fff;
}

.auth-gate {
  display: flex;
  gap: 14px;
  padding: 15px;
  margin-bottom: 22px;
  border: 1px solid rgba(165, 108, 22, 0.17);
  border-radius: var(--radius-md);
  background: var(--warning-soft);
}

.auth-gate strong { display: block; margin-bottom: 3px; }
.auth-gate p { margin: 0; color: var(--muted); font-size: 0.82rem; }
.gate-icon { color: var(--warning); }

.voice-stage {
  min-height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
}

.record-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 1px solid rgba(100, 116, 223, 0.2);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(100, 116, 223, 0.16), rgba(255, 255, 255, 0.8) 64%);
  color: var(--accent);
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 0 0 14px rgba(100, 116, 223, 0.04), 0 0 0 28px rgba(100, 116, 223, 0.025);
  transition: transform 160ms ease, background 160ms ease;
}

.record-button:hover { transform: scale(1.03); }
.record-button.is-recording { background: var(--danger-soft); color: var(--danger); }

.record-button.is-recording::after {
  content: "";
  position: absolute;
  inset: -16px;
  border: 1px solid rgba(200, 79, 91, 0.25);
  border-radius: 50%;
  animation: pulse-ring 1.25s infinite;
}

.voice-copy { max-width: 500px; margin-top: 38px; }
.voice-copy h2 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.25rem); letter-spacing: -0.04em; }
.voice-copy p { margin: 11px 0 0; color: var(--muted); }

.voice-wave {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 44px;
  margin-top: 28px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.voice-wave.is-active { opacity: 1; }
.voice-wave span { width: 4px; height: 10px; border-radius: 999px; background: var(--accent); animation: wave 900ms ease-in-out infinite; }
.voice-wave span:nth-child(2), .voice-wave span:nth-child(6) { animation-delay: 100ms; }
.voice-wave span:nth-child(3), .voice-wave span:nth-child(5) { animation-delay: 200ms; }
.voice-wave span:nth-child(4) { animation-delay: 300ms; }

.review-panel { min-height: 530px; }

.review-heading,
.events-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.review-heading h2,
.events-heading h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.035em;
}

.events-heading-actions,
.event-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ai-badge,
.count-badge,
.sync-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

.ai-badge { color: var(--accent-strong); background: var(--accent-soft); }
.count-badge { min-width: 30px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--border); }

.event-preview {
  margin: 30px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.58);
}

.event-preview div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

.event-preview div:last-child { border-bottom: 0; }
.event-preview dt { color: var(--subtle); font-size: 0.78rem; }
.event-preview dd { margin: 0; color: var(--text); font-weight: 600; overflow-wrap: anywhere; }

.events-card {
  padding: 26px;
  position: sticky;
  top: 24px;
  min-height: 580px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 223, 0.28) transparent;
}

.event-card {
  position: relative;
  display: flex;
  gap: 13px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 5px 18px rgba(61, 73, 104, 0.045);
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.event-card:hover {
  transform: translateY(-1px);
  border-color: rgba(100, 116, 223, 0.2);
  box-shadow: 0 8px 22px rgba(61, 73, 104, 0.07);
}

.event-accent {
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, #7585e4, #a997df);
  flex: none;
}

.event-content { min-width: 0; flex: 1; }
.event-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.event-title { margin: 0; font-size: 0.94rem; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.event-date { margin: 7px 0 0; color: var(--muted); font-size: 0.8rem; }
.event-meta { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.event-meta span { font-size: 0.68rem; color: var(--subtle); }

.sync-badge {
  min-height: 22px;
  flex: none;
  padding: 3px 7px;
  color: var(--success);
  background: var(--success-soft);
}

.icon-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--subtle);
  cursor: pointer;
  font-size: 1.1rem;
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.icon-button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(100, 116, 223, 0.12);
}

.icon-button:active { transform: scale(0.94); }
.delete-event:hover { background: var(--danger-soft); color: var(--danger); border-color: rgba(200, 79, 91, 0.12); }
.refresh-events:disabled { opacity: 0.42; cursor: not-allowed; }
.refresh-events.is-loading { animation: spin 900ms linear infinite; }

.empty-state {
  min-height: 430px;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 30px;
}

.empty-state h3 { margin: 24px 0 7px; }
.empty-state p { max-width: 280px; margin: 0; color: var(--muted); font-size: 0.85rem; }

.empty-orbit {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  position: relative;
  background: rgba(255, 255, 255, 0.42);
}

.empty-orbit::before {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  top: -6px;
  left: 31px;
  box-shadow: 0 0 24px rgba(100, 116, 223, 0.4);
}

.toast-region {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100% - 36px));
}

.toast {
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.86rem;
  animation: toast-in 180ms ease-out;
}

.toast.is-error { border-color: rgba(200, 79, 91, 0.3); }
.toast.is-success { border-color: rgba(37, 132, 104, 0.3); }

@keyframes pulse-ring { 0% { transform: scale(0.92); opacity: 1; } 100% { transform: scale(1.18); opacity: 0; } }
@keyframes wave { 0%, 100% { height: 10px; } 50% { height: 36px; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .events-card { position: static; min-height: 0; max-height: none; }
  .events-list { overflow: visible; }
  .empty-state { min-height: 260px; }
}

@media (max-width: 620px) {
  .site-header,
  .app-shell { width: min(calc(100% - 28px), var(--max-width)); }
  .site-header { min-height: 74px; }
  .app-shell { padding-top: 18px; }
  .user-chip > #userName { display: none; }
  .tabs { grid-template-columns: 1fr; }
  .tab { text-align: left; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .panel-wrap { padding: 20px; }
  .panel,
  .review-panel { min-height: 0; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .event-preview div { grid-template-columns: 1fr; gap: 4px; }
  .voice-stage { min-height: 430px; padding-inline: 4px; }
  .events-card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
