/* ── Reset & variables ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Inter', system-ui, sans-serif;
  --color-bg: #f9fafb;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #111827;
  --color-muted: #6b7280;
  --color-today: #f59e0b;
  --color-weekend: #f3f4f6;
  --radius: 8px;
  --cell-w: 28px;
  --cell-h: 28px;
  --bar-h: 18px;
  --bar-gap: 2px;
  --month-label-w: 80px;
  --dow-label-h: 24px;
  /* palette */
  --orange: #d97706; --blue: #2563eb; --green: #16a34a;
  --red:    #dc2626; --purple:#9333ea; --pink:  #db2777;
  --teal:   #0d9488; --gray:  #4b5563;
}

body { font-family: var(--font); background: var(--color-bg); color: var(--color-text); min-height: 100vh; }

/* ── Layout ─────────────────────────────────────────── */
.container { padding: 0 1.5rem; }
header { padding: 1.5rem 0 1rem; }
header h1 { font-size: 1.4rem; font-weight: 700; }
header p  { color: var(--color-muted); font-size: .9rem; margin-top: .25rem; }

/* ── Landing ─────────────────────────────────────────── */
.landing { display: flex; flex-direction: column; gap: 2rem; padding: 3rem 0; }
.landing h1 { font-size: 2rem; font-weight: 800; }
.landing p  { color: var(--color-muted); max-width: 480px; line-height: 1.6; }
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.5rem; }
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: .04em; }
.form-group input { padding: .6rem .75rem; border: 1px solid var(--color-border); border-radius: 6px; font-size: .95rem; font-family: var(--font); outline: none; background: var(--color-surface); color: var(--color-text); }
.form-group input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .65rem 1.25rem; border-radius: 6px; font-size: .9rem; font-weight: 600; border: none; cursor: pointer; text-decoration: none; transition: opacity .15s; font-family: var(--font); }
.btn:hover { opacity: .85; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-danger  { background: var(--red);  color: #fff; }
.btn-sm      { padding: .35rem .75rem; font-size: .8rem; }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }

/* ── Year grid ──────────────────────────────────────── */
.year-grid { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 100px; }
.dow-header { display: flex; padding-left: var(--month-label-w); height: var(--dow-label-h); align-items: center; min-width: max-content; }
.dow-header span { width: var(--cell-w); text-align: center; font-size: .7rem; font-weight: 700; color: var(--color-muted); flex-shrink: 0; }
.month-row { display: flex; align-items: flex-start; min-height: var(--cell-h); margin-bottom: 4px; position: relative; min-width: max-content; }
.month-label { width: var(--month-label-w); flex-shrink: 0; font-size: .78rem; font-weight: 600; color: var(--color-muted); padding-top: 6px; position: sticky; left: 0; background: var(--color-bg); z-index: 10; }
.month-days  { display: flex; flex-wrap: nowrap; position: relative; }
.day-cell {
  width: var(--cell-w); height: var(--cell-h);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: .72rem; position: relative; border-radius: 50%;
}
.day-cell:not(.empty) { cursor: pointer; }
.day-cell.weekend     { background: #d1d5db; border-radius: 4px; font-weight: 600; }
.day-cell.today       { outline: 2px solid var(--color-today); outline-offset: -2px; border-radius: 50%; font-weight: 700; }
.day-cell.empty       { pointer-events: none; }
.day-cell.holiday     { background: #fef3c7; box-shadow: inset 0 0 0 2px #f59e0b; border-radius: 4px; font-weight: 600; }

/* ── Event bars ─────────────────────────────────────── */
.events-layer { position: absolute; top: var(--cell-h); left: 0; pointer-events: none; }
.event-bar {
  position: absolute; height: var(--bar-h); pointer-events: all;
  display: flex; align-items: center; padding: 0 6px; cursor: pointer;
  font-size: .68rem; font-weight: 600; color: #fff; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
}
.event-bar.round-left  { border-radius: 9px 0 0 9px; }
.event-bar.round-right { border-radius: 0 9px 9px 0; }
.event-bar.round-both  { border-radius: 9px; }
.event-bar.color-orange { background: var(--orange); }
.event-bar.color-blue   { background: var(--blue); }
.event-bar.color-green  { background: var(--green); }
.event-bar.color-red    { background: var(--red); }
.event-bar.color-purple { background: var(--purple); }
.event-bar.color-pink   { background: var(--pink); }
.event-bar.color-teal   { background: var(--teal); }
.event-bar.color-gray   { background: var(--gray); }

/* ── FAB ────────────────────────────────────────────── */
.fab { position: fixed; bottom: max(1.5rem, env(safe-area-inset-bottom, 1.5rem)); right: max(1.5rem, env(safe-area-inset-right, 1.5rem)); width: 52px; height: 52px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 1.5rem; border: none; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.2); display: flex; align-items: center; justify-content: center; z-index: 100; font-family: var(--font); }
.fab:hover { opacity: .9; }

/* ── Modal ──────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal { background: var(--color-surface); border-radius: 16px 16px 0 0; padding: 1.5rem; width: 100%; max-width: 480px; }
@media (min-width: 640px) { .modal { border-radius: var(--radius); } }
.modal h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }
.hidden { display: none !important; }

/* ── Color swatches ─────────────────────────────────── */
.color-picker { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: transform .1s; }
.swatch:hover { transform: scale(1.1); }
.swatch.selected { border-color: var(--color-text); }
.swatch[data-color=orange] { background: var(--orange); }
.swatch[data-color=blue]   { background: var(--blue); }
.swatch[data-color=green]  { background: var(--green); }
.swatch[data-color=red]    { background: var(--red); }
.swatch[data-color=purple] { background: var(--purple); }
.swatch[data-color=pink]   { background: var(--pink); }
.swatch[data-color=teal]   { background: var(--teal); }
.swatch[data-color=gray]   { background: var(--gray); }

/* ── Admin ──────────────────────────────────────────── */
.admin-nav { background: var(--color-text); color: #fff; padding: .75rem 1.5rem; display: flex; gap: 1.5rem; align-items: center; }
.admin-nav a { color: #fff; text-decoration: none; font-size: .9rem; opacity: .8; }
.admin-nav a:hover { opacity: 1; }
.admin-nav .brand { font-weight: 700; opacity: 1; margin-right: auto; font-family: var(--font); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--color-border); font-size: .88rem; }
th { font-weight: 600; color: var(--color-muted); text-transform: uppercase; font-size: .75rem; letter-spacing: .04em; }
tr:hover td { background: #f9fafb; }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 9999px; font-size: .75rem; font-weight: 600; }
.badge-blue { background: #eff6ff; color: var(--blue); }

/* ── Utilities ──────────────────────────────────────── */
.text-muted { color: var(--color-muted); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.error-msg { color: var(--red); font-size: .85rem; padding: .5rem; background: #fef2f2; border-radius: 6px; }

/* ── Alternating month rows ─────────────────────────── */
#year-grid > .month-row:nth-child(even) {
  background: rgba(0,0,0,.025);
  box-shadow: 0 2px 6px rgba(0,0,0,.07);
  border-radius: 6px;
}

/* ── Holiday picker ──────────────────────────────────── */
.holiday-picker { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }
.holiday-picker label { font-size: .85rem; font-weight: 600; color: var(--color-muted); }
.holiday-picker select { font-size: .85rem; padding: .2rem .5rem; border: 1px solid var(--color-border); border-radius: 4px; background: var(--color-surface); color: var(--color-text); font-family: var(--font); cursor: pointer; }

/* ── Mobile polish ──────────────────────────────────── */
@media (max-width: 480px) {
  :root { --cell-w: 22px; --cell-h: 22px; --bar-h: 16px; }
  .month-label { width: 56px; font-size: .68rem; }
  .dow-header  { padding-left: 56px; }
}
