/* InSync Hub. Tokens and rules: skill insync-design-system (dark frame, gold accent, cream and white work surface). */
@font-face { font-family: 'Inter'; src: url('/static/fonts/inter.woff2') format('woff2'); font-weight: 600 800; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/static/fonts/instrument.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/static/fonts/jbmono.woff2') format('woff2'); font-weight: 500; font-display: swap; }

:root {
  --void: #08070d; --obsidian: #0f0e17; --slate: #1a1829; --graphite: #262338; --ash: #34304a;
  --gold: #d4a84b; --gold-bright: #ecc45f; --gold-dim: rgba(212,168,75,.12); --border-gold: rgba(212,168,75,.25);
  --text-primary: #f0ede6; --text-secondary: #9994ab; --text-dim: #8f87ab;
  --font-head: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-label: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --radius: 2px;

  /* work surface, light */
  --board: #f4f2ec; --sheet: #ffffff; --sheet-2: #faf7f0; --rule: #e6e2d9; --rule-field: #8a857c;
  --ink: #16151f; --ink-2: #5a554d; --ink-3: #6b6560; --link: #846729; --focus: #a87f24;
  --mine: #faf3e2; --mine-rule: #e9d8ad; --code: #faf7f0;
  --ok: #2f7d4f; --warn: #b26a00; --bad: #b3261e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --board: #08070d; --sheet: #0f0e17; --sheet-2: #1a1829; --rule: #262338; --rule-field: #6a6585;
    --ink: #f0ede6; --ink-2: #d6d2c8; --ink-3: #9994ab; --link: #d4a84b; --focus: #d4a84b;
    --mine: #1d1a14; --mine-rule: #4a3d20; --code: #1a1829;
    --ok: #6fcf97; --warn: #f2b27a; --bad: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font: 400 16px/1.55 var(--font-body); color: var(--ink); background: var(--board); -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin: 0; color: inherit; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.eyebrow { font: 500 11px/1.2 var(--font-label); letter-spacing: 2px; text-transform: uppercase; color: var(--gold); margin: 0; }
.note { color: var(--ink-2); margin: 8px 0 0; }
.err { color: var(--bad); margin: 12px 0 0; font-weight: 600; }
.lbl { display: block; font: 500 11px/1.2 var(--font-label); letter-spacing: 2px; text-transform: uppercase; color: var(--ink-3); margin: 18px 0 6px; }
.input { width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--rule-field); border-radius: var(--radius); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  font: 700 15px/1 var(--font-body); border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 36px; padding: 8px 12px; font-size: 14px; }
.btn-primary { background: var(--gold); color: var(--void); }
.btn-primary:hover { background: var(--gold-bright); }
.btn-primary:disabled { background: var(--ash); color: var(--text-secondary); cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule-field); }
.btn-ghost:hover { border-color: var(--focus); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; background: transparent;
  color: var(--text-primary); font-size: 22px; cursor: pointer; text-decoration: none; border-radius: var(--radius); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: inherit; text-decoration: underline; cursor: pointer; }

/* sign in */
.authpage { background: var(--obsidian); color: var(--text-primary); display: grid; place-items: center; min-height: 100%; padding: 24px 16px; }
.authcard { width: 100%; max-width: 400px; background: var(--void); border: 1px solid var(--border-gold); border-top: 2px solid var(--gold); padding: 32px 24px; }
.authcard h1 { font-size: 30px; margin: 6px 0 4px; }
.authcard .note { color: var(--text-secondary); margin-bottom: 20px; }
.authcard .lbl { color: var(--text-secondary); }
.authcard .input { background: var(--obsidian); color: var(--text-primary); border-color: var(--ash); margin-bottom: 18px; }
.authcard .err { color: #ff8a80; }
.authlogo { display: block; margin-bottom: 20px; height: 48px; width: auto; }

/* app shell */
.apppage { overflow: hidden; }
.shell { display: grid; grid-template-columns: 300px 1fr; height: 100vh; height: 100dvh; }
.side { background: var(--obsidian); color: var(--text-primary); display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--graphite); padding-top: env(safe-area-inset-top, 0px); }
.sidehead { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 2px solid var(--gold); }
.sidehead img { height: 29px; width: auto; }
.rooms { flex: 1; overflow-y: auto; padding: 8px 0; }
.rooms .grp { font: 500 11px/1.2 var(--font-label); letter-spacing: 2px; text-transform: uppercase; color: var(--text-secondary); padding: 16px 16px 6px; margin: 0; }
.room { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; width: 100%; text-align: left; background: none; border: 0;
  border-left: 3px solid transparent; color: var(--text-primary); padding: 10px 16px 10px 13px; cursor: pointer; font: inherit; min-height: 56px; }
.room:hover { background: var(--slate); }
.room[aria-current="true"] { background: var(--slate); border-left-color: var(--gold); }
.room .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room .tm { font: 500 11px/1.6 var(--font-label); color: var(--text-secondary); }
.room .pv { grid-column: 1 / -1; color: var(--text-secondary); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room .busy { color: var(--gold); }
.sidefoot { display: grid; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--graphite); }
.side .btn-ghost { color: var(--text-primary); border-color: var(--ash); }
.side .btn-ghost:hover { border-color: var(--gold); }
.side .btn-danger { color: #ff8a80; border-color: #ff8a80; }
.side .btn-danger:hover { background: #ff8a80; color: var(--void); }
.side .btn-danger.on { background: #ff8a80; color: var(--void); }

.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--board); }
.empty { display: flex; flex-direction: column; justify-content: center; padding: 32px; max-width: 560px; }
.empty h1 { font-size: 32px; margin-top: 8px; }
.chathead { display: flex; align-items: center; gap: 8px; background: var(--obsidian); color: var(--text-primary);
  border-bottom: 2px solid var(--gold); padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px 16px; min-height: 60px; }
.chathead .btn-ghost { color: var(--text-primary); border-color: var(--ash); }
.chattitle { flex: 1; min-width: 0; }
.chattitle h1 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chattitle .who { margin: 2px 0 0; font: 500 11px/1.3 var(--font-label); letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-secondary); }
.back { display: none; margin-left: -8px; }
.banner { background: #ff8a80; color: var(--void); padding: 10px 16px; font-weight: 600; }

.log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.more { align-self: center; }
.msg { max-width: min(760px, 92%); background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 14px 12px; }
.msg.mine { align-self: flex-end; background: var(--mine); border-color: var(--mine-rule); }
.msg.sys { align-self: center; background: transparent; border: 0; padding: 0 8px; color: var(--ink-3); font-size: 14px; text-align: center; }
.msg .meta { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.msg .au { font: 500 11px/1.2 var(--font-label); letter-spacing: 2px; text-transform: uppercase; color: var(--ink); font-weight: 700; }
.msg .au.outside::after { content: " outside"; color: var(--ink-3); font-weight: 500; letter-spacing: 1px; }
.msg .tm { font: 500 11px/1.2 var(--font-label); color: var(--ink-3); }
.msg .body { overflow-wrap: anywhere; color: var(--ink); }
.msg .body p { margin: 0 0 8px; }
.msg .body p:last-child { margin-bottom: 0; }
.msg .body ul, .msg .body ol { margin: 4px 0 8px; padding-left: 22px; }
.msg .body h3 { font-size: 17px; margin: 10px 0 4px; }
.msg .body code { font: 500 .88em var(--font-label); background: var(--code); padding: 1px 4px; border-radius: var(--radius); }
.msg .body pre { background: var(--code); border: 1px solid var(--rule); padding: 10px; overflow-x: auto; margin: 6px 0 8px; }
.msg .body pre code { background: none; padding: 0; }
.msg .body .tw { overflow-x: auto; margin: 6px 0 8px; }
.msg .body table { border-collapse: collapse; font-size: 14px; }
.msg .body th, .msg .body td { border: 1px solid var(--rule); padding: 4px 8px; text-align: left; vertical-align: top; }
.msg .body th { background: var(--sheet-2); }
.mention { font-weight: 700; color: var(--link); }

.working { padding: 8px 16px; color: var(--ink-2); font-size: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--rule); background: var(--sheet); }
.working .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .working .dot { animation: none; } }

.composer { border-top: 1px solid var(--rule); background: var(--sheet); padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); }
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 44px; max-height: 40vh; resize: none; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--rule-field); border-radius: var(--radius); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips:not(:empty) { margin-bottom: 8px; }
.chip { font: 500 12px/1 var(--font-label); letter-spacing: 1px; min-height: 32px; padding: 6px 10px; border-radius: var(--radius);
  border: 1px solid var(--rule-field); background: var(--sheet-2); color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--focus); }

/* dialog */
.dlg { border: 1px solid var(--rule); border-top: 2px solid var(--gold); border-radius: var(--radius); padding: 24px; width: min(420px, calc(100% - 32px));
  background: var(--sheet); color: var(--ink); }
.dlg::backdrop { background: rgba(8,7,13,.6); }
.dlg h2 { font-size: 22px; }
.checks { display: grid; gap: 8px; }
.checks label { display: flex; gap: 10px; align-items: center; min-height: 36px; }
.checks input { width: 20px; height: 20px; accent-color: var(--focus); }
.dlgbtns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* settings */
.pagepage { background: var(--board); }
.pagehead { display: flex; align-items: center; gap: 12px; background: var(--obsidian); color: var(--text-primary); border-bottom: 2px solid var(--gold);
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px 8px; min-height: 60px; }
.pagehead img { height: 29px; width: auto; }
.page { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; display: grid; gap: 16px; }
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px; overflow-x: auto; }
.card h2 { font-size: 20px; margin-bottom: 8px; }
.card .btn { margin: 12px 8px 0 0; }
.status { font-weight: 600; margin: 12px 0 0; }
.tbl { border-collapse: collapse; width: 100%; font-size: 14px; margin-top: 8px; }
.tbl th { background: var(--sheet-2); text-align: left; font: 500 11px/1.2 var(--font-label); letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink); }
.tbl th, .tbl td { border-bottom: 1px solid var(--rule); padding: 8px; white-space: nowrap; }
.inline { display: inline; }

/* phone */
@media (max-width: 859px) {
  .shell { grid-template-columns: 1fr; }
  .empty { display: none; }
  .shell.inroom .side { display: none; }
  .shell:not(.inroom) .chat { display: none; }
  .back { display: inline-flex; }
  .msg { max-width: 94%; }
  .chathead .btn.small { padding: 8px 10px; }
}
@media (min-width: 860px) {
  .shell.inroom .empty { display: none; }
  .shell:not(.inroom) .chat { display: none; }
}
