:root {
  --bg: #0b0b0d;
  --panel: #141418;
  --panel-2: #1b1b21;
  --border: #2a2a33;
  --text: #ece8df;
  --muted: #9a958a;
  --gold: #c9a227;
  --gold-soft: #e3c25a;
  --mine: #3fb68b;
  --empty: #1f2029;
  --danger: #e26d5a;
  --cell-h: 14px;
  --cell-w: 50px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: rgba(11,11,13,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; letter-spacing: .04em; color: #111; background: linear-gradient(135deg, var(--gold-soft), var(--gold)); }
.brand-name { font-weight: 700; letter-spacing: .02em; }
.brand-sub { font-size: 12.5px; color: var(--muted); }
.session { display: flex; align-items: center; gap: 10px; font-size: 14px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.btn { appearance: none; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #111; font-weight: 600; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
input, select { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; }
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 10px; }
.row label { display: flex; align-items: center; gap: 6px; }

.auth { max-width: 460px; }
.auth form { display: grid; gap: 10px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { border: 1px solid var(--border); background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; }
.tab[aria-selected="true"] { color: #111; background: var(--gold); border-color: var(--gold); font-weight: 600; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.legend .ramp { display: flex; }
.legend .ramp span { width: 16px; height: 12px; }

.month { display: grid; gap: 10px; }
.month { margin-top: 8px; }
.month-title { font-size: 20px; font-weight: 700; margin: 4px 2px 0; }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.pane h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pane .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.scroller { overflow-x: auto; padding-bottom: 4px; }

.grid { display: inline-grid; position: relative; user-select: none; -webkit-user-select: none; touch-action: none; padding-bottom: 12px; }
.grid.group { touch-action: pan-x pan-y; }
.grid .corner, .grid .dayhead, .grid .timelabel { font-size: 11.5px; color: var(--muted); }
.grid .dayhead { text-align: center; padding: 0 2px 6px; line-height: 1.2; white-space: nowrap; position: relative; }
.grid .dayhead b { display: block; color: var(--text); font-size: 13px; }
.grid .dayhead .weekday { text-transform: capitalize; }
.grid .dayhead .x { position: absolute; top: -6px; right: -2px; width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--panel-2); color: var(--muted); cursor: pointer; font-size: 10px; padding: 0; opacity: 0; transition: opacity .15s; }
.grid .dayhead:hover .x, .grid .dayhead .x:focus { opacity: 1; }
@media (hover: none) { .grid .dayhead .x { opacity: .7; } }
.grid .timelabel.end { height: 0; }
.grid .endpad { height: 0; }
.grid .dayhead .x:hover { color: var(--danger); }
.grid .timelabel { text-align: right; padding-right: 6px; transform: translateY(-7px); height: var(--cell-h); white-space: nowrap; }
.cell { width: var(--cell-w); height: var(--cell-h); background: var(--empty); border-right: 1px solid #0f0f13; border-bottom: 1px solid #0f0f13; }
.cell.hour { border-top: 1px solid #3a3a46; }
.cell.dayfirst { border-left: 1px solid #0f0f13; }
.mine .cell { cursor: pointer; }
.mine .cell.on { background: var(--mine); }
.mine .cell.preview-on { background: #7fdcb8; }
.mine .cell.preview-off { background: #1d3a2f; }
.group .cell.hover { outline: 2px solid var(--text); outline-offset: -2px; }

.best-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.best-item:last-child { border-bottom: 0; }
.best-item .count { color: var(--gold); font-weight: 700; white-space: nowrap; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); text-transform: none; }
.admin-row .name { text-transform: capitalize; }
.admin-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: end; }
.badge { font-size: 11px; color: #111; background: var(--gold); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }

/* v0.2 */
#months.side { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; align-items: start; }
#months.stack { display: grid; gap: 16px; }
.single { display: grid; }
.legend .key { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.sw.concierto, .ev.concierto { background: rgba(214, 64, 64, .78); }
.sw.llamado, .ev.llamado { background: rgba(64, 132, 230, .78); }
.sw.ensayo, .ev.ensayo { background: rgba(150, 100, 230, .7); }
.sw.otro, .ev.otro { background: rgba(160, 160, 170, .6); }
.ev { pointer-events: none; z-index: 1; border-radius: 4px; margin: 1px 2px; overflow: hidden; display: flex; align-items: flex-start; justify-content: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.ev span { font-size: 9.5px; line-height: 1.15; color: #fff; text-align: center; padding: 2px 1px; font-weight: 600; text-shadow: 0 1px 1px rgba(0,0,0,.5); }
.tev { font-size: 12.5px; font-weight: 600; margin: 2px 0; padding-left: 8px; border-left: 3px solid; }
.tev.concierto { border-color: #d64040; color: #f0a0a0; }
.tev.ensayo { border-color: #9664e6; color: #c8b0f4; }
.tev.otro { border-color: #a0a0aa; color: #ccc; }
.grid .dayhead .resp { display: block; font-size: 10.5px; margin-top: 2px; border-radius: 6px; padding: 0 3px; }
.grid .dayhead .resp.ok { color: #7fdcb8; }
.grid .dayhead .resp.warn { color: #f0a35a; }
.mine .cell.cant { background: repeating-linear-gradient(135deg, #2a1a1a 0 4px, #1f2029 4px 8px); }
.dayfoot { display: grid; gap: 3px; padding: 6px 1px 0; }
.mini { appearance: none; font: inherit; font-size: 10px; line-height: 1.1; padding: 4px 1px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); cursor: pointer; }
.mini:hover { border-color: var(--gold); color: var(--text); }
.mini.cant-btn.active { background: #5a2020; border-color: #d64040; color: #ffd0d0; }
.mini.place-btn.custom { border-color: var(--gold); color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { appearance: none; font: inherit; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.chip.on { background: #173a2e; border-color: #3fb68b; color: #bff0dc; font-weight: 600; }
.pending.warn { border-color: #6a4a1c; background: #1e1910; }
.pending.ok { border-color: #1f4a3a; background: #101c17; }
.weeks { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.week { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 10px; align-content: start; }
.week-title { font-weight: 700; font-size: 14px; color: var(--gold); }
.wday { display: grid; gap: 3px; padding: 8px; border-radius: 8px; border: 1px solid transparent; }
.wday.top { border-color: #6a5a1c; background: #1f1c11; }
.wday-head { display: flex; align-items: baseline; gap: 4px; }
.wday-head .count { margin-left: auto; color: var(--gold); font-weight: 700; }
.who { font-size: 12.5px; color: var(--text); }
.who .lbl { color: var(--muted); }
.who.yes .lbl { color: #7fdcb8; }
.who.no { color: var(--muted); }
.who.pend { color: #f0a35a; }
.who.pend .lbl { color: #f0a35a; font-weight: 600; }
.tip .pend { color: #f0a35a; margin-top: 4px; }
.pop { position: absolute; z-index: 20; width: 240px; background: #000; border: 1px solid var(--gold); border-radius: 12px; padding: 12px; display: grid; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.6); }
.pop-title { font-weight: 700; color: var(--gold); }
.pop-list { display: grid; gap: 6px; padding-left: 10px; border-left: 2px solid var(--border); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
label.check.disabled { color: var(--muted); }
.evform { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.evform button { grid-column: 1 / -1; }
.evform label[hidden] { display: none; }

.tip { position: fixed; z-index: 10; pointer-events: none; max-width: 280px; background: #000; border: 1px solid var(--gold); border-radius: 10px; padding: 10px 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.tip .t { color: var(--gold); font-weight: 600; margin-bottom: 4px; }
.tip .yes { color: var(--text); }
.tip .no { color: var(--muted); margin-top: 4px; }

@media (max-width: 560px) {
  :root { --cell-w: 36px; --cell-h: 20px; }
  .btn.small { padding: 7px 10px; }
  .pane h2 { flex-direction: column; align-items: start; gap: 2px; }
  main { padding: 10px; }
}

/* v0.2 readability pass */
.weeks { align-items: start; }
.nowrap { white-space: nowrap; }
.who.yes .nm { color: #bff0dc; font-weight: 600; }
.who.no { color: #b3ada2; }
.who.pend, .who.pend .lbl { font-weight: 400; color: #d9a066; }
.mini { color: var(--text); font-size: 10.5px; }
.group .ev { background: transparent !important; border: 2px solid; box-shadow: none; }
.group .ev span { background: rgba(0,0,0,.55); border-radius: 3px; margin-top: 2px; }
.group .ev.concierto { border-color: #e05050; }
.group .ev.llamado { border-color: #4a90f0; }
.group .ev.ensayo { border-color: #a070f0; }
.group .ev.otro { border-color: #aaa; }
.ev + .ev { margin-top: 2px; }

/* keep wide grids scrolling inside their card instead of widening the page */
main { grid-template-columns: minmax(0, 1fr); }
#months.stack, .pair, .single { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.month, .pane, .card { min-width: 0; }
.legend { flex-wrap: wrap; }

/* labels inside event blocks must never resize the grid rows */
.ev { position: relative; min-height: 0; }
.ev span { position: absolute; top: 2px; left: 1px; right: 1px; }
.ev + .ev { margin-top: 1px; }
.admin-grid > div { min-width: 0; }
.evform input, .evform select { width: 100%; min-width: 0; }

/* v0.3 — hidden must always win over display rules (popover never closed before) */
[hidden] { display: none !important; }

/* compact sign-in strip */
.auth { max-width: none; padding: 12px 16px; }
.auth form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 18px; align-items: center; }
.auth h2 { font-size: 15px; margin: 0 0 2px; }
.auth .auth-text p { margin: 0; }
.auth-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.auth-fields input { width: 150px; padding: 6px 9px; }
.auth .error { grid-column: 1 / -1; min-height: 0; margin: 0; }
.auth .error:empty { display: none; }
@media (max-width: 760px) {
  .auth form { grid-template-columns: minmax(0, 1fr); }
  .auth-fields input { flex: 1 1 130px; width: auto; }
}

/* administration in tabs */
.admin-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.admin-head h2 { margin: 0; }
.admin-panel { border-top: 1px solid var(--border); padding-top: 6px; }
.admin-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 8px 28px; }
.admin-cols > div { min-width: 0; }
.evform .wide { grid-column: 1 / -1; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 0 28px; }
.admin-row .acts { flex-wrap: nowrap; }
@media (max-width: 760px) {
  .auth { padding: 10px 12px; }
  .auth h2 { font-size: 14px; }
  .auth .auth-text p { font-size: 12px; line-height: 1.35; }
  .auth-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .auth-fields input { width: 100%; }
  .auth-fields .btn { padding: 7px 8px; }
}
.evform { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.evform .half { grid-column: span 3; }
.evform .third { grid-column: span 2; }
.evform .wide, .evform button { grid-column: 1 / -1; }

/* v0.4 */
.people { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.person { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.badge.new { background: #3fb68b; }
.place-line { display: grid; gap: 1px; }
.place-line a, .who.places a { color: var(--gold-soft); text-decoration: none; }
.place-line a:hover, .who.places a:hover { text-decoration: underline; }
.placeform { display: grid; gap: 8px; margin-top: 10px; }
.access-state { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); }
.access-state .code { color: var(--gold); letter-spacing: .04em; }
.access-toggle { margin-top: 12px; }
.auth-fields #authCode { width: 150px; }
@media (max-width: 760px) {
  .auth-fields #authCode { grid-column: 1 / -1; width: 100%; }
}

/* v0.5 code dialog */
.codebox { background: var(--panel); color: var(--text); border: 1px solid var(--gold); border-radius: 14px; padding: 18px; width: min(92vw, 360px); }
.codebox::backdrop { background: rgba(0,0,0,.6); }
.codebox h2 { margin: 0 0 6px; }
.codebox input { width: 100%; margin-top: 8px; }
.codebox .error:empty { display: none; }

/* v0.6 hosts */
.host-row { border-top: 1px solid var(--border); padding-top: 8px; display: grid; gap: 6px; }
.host-q { font-size: 13px; font-weight: 600; }
.host-btns { display: flex; gap: 6px; }
.host-btns .mini { padding: 5px 14px; font-size: 12px; }
.mini.host-yes.active { background: #173a2e; border-color: #3fb68b; color: #bff0dc; }
.mini.host-no.active { background: #5a2020; border-color: #d64040; color: #ffd0d0; }
.who.places .host-no { opacity: .55; text-decoration: line-through; }
.host-pick { display: flex; gap: 6px; align-items: center; margin-top: 4px; color: var(--muted); }
.host-pick select { padding: 3px 6px; font-size: 12.5px; }
.topbar .home-link { color: var(--muted); text-decoration: none; font-size: 13px; margin-left: 12px; }
.topbar .home-link:hover { color: var(--gold); }
.topbar { flex-wrap: wrap; }
.brand { min-width: 0; flex-wrap: wrap; }
@media (max-width: 560px) {
  .topbar .home-link { margin-left: 0; }
  .brand-sub { display: none; }
  .session { flex-wrap: wrap; gap: 6px; }
}

.chip.taken { opacity: .5; cursor: default; }
#myPlaces h3 { margin-top: 16px; }

.host-list { display: grid; gap: 10px; margin-top: 6px; }
.host-default { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.host-default .mini { padding: 6px 12px; font-size: 12.5px; }
.host-default .mini.active:not(.host-yes):not(.host-no) { border-color: var(--gold); color: var(--gold); }
