:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #dde1e6;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --danger: #dc2626;
  --ok: #15803d;
  --radius: 8px;
  color-scheme: light;

  --fc-border-color: var(--border);
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: #eef0f3;
  --fc-today-bg-color: #eaf1ff;
  --fc-button-bg-color: var(--surface);
  --fc-button-text-color: var(--text);
  --fc-button-border-color: var(--border);
  --fc-button-hover-bg-color: #eef0f3;
  --fc-button-hover-border-color: var(--border);
  --fc-button-active-bg-color: var(--primary);
  --fc-button-active-border-color: var(--primary);
  --fc-list-event-hover-bg-color: #eef0f3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1d23;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --border: #30353d;
    --primary: #3b82f6;
    --danger: #f87171;
    --ok: #4ade80;
    color-scheme: dark;

    --fc-neutral-bg-color: #23272e;
    --fc-today-bg-color: #1d2a40;
    --fc-button-hover-bg-color: #23272e;
    --fc-list-event-hover-bg-color: #23272e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

h1, h2 { margin: 0; line-height: 1.2; }
.app-title { font-size: 1.25rem; }
h2 { font-size: 1.15rem; display: flex; align-items: center; gap: .5rem; }

/* --- form controls --- */
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 500; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]), select, textarea {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-weight: 400;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  padding: .5rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
button:hover { filter: brightness(.96); }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--primary); padding: 0; justify-self: start; }

/* --- layout helpers --- */
.stack { display: grid; gap: .9rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.grow > * { flex: 1 1 10rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; margin: 0; }
.error { color: var(--danger); margin: 0; font-size: .9rem; }
.error.ok { color: var(--ok); }
p { margin: 0; }
a { color: var(--primary); }
.fc a { color: inherit; text-decoration: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}
.centered { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .app-title { margin-bottom: 1rem; }

.tabs { display: flex; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab { border: 0; border-radius: 0; background: none; padding: .5rem .75rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }

/* --- app --- */
#app-screen { max-width: 1200px; margin: 0 auto; padding: 0 1rem 2rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.notice { padding: .75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 1rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; flex-direction: row; align-items: center; gap: .4rem;
  padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-weight: 400; cursor: pointer; user-select: none;
}
.chip input { display: none; }
.chip:has(input:not(:checked)) { opacity: .45; }
.dot { width: .7rem; height: .7rem; border-radius: 50%; flex: none; display: inline-block; }

#calendar { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .75rem; }
.fc .fc-toolbar { flex-wrap: wrap; gap: .5rem; }
.fc .fc-toolbar-title { font-size: 1.15rem; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: var(--primary-text); }
.fc .fc-event { cursor: pointer; }
.fc .fc-event.mine { box-shadow: inset 3px 0 0 rgba(0,0,0,.35); }
.fc-theme-standard .fc-list-day-cushion { background: var(--fc-neutral-bg-color); }

/* --- dialogs --- */
dialog {
  width: min(480px, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 1.25rem;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }
.note { white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .fc .fc-toolbar { flex-direction: column; align-items: stretch; }
  .fc .fc-toolbar-chunk { display: flex; justify-content: center; }
  #calendar { padding: .4rem; }
  .toolbar > .primary { width: 100%; }
}
