/*
 * restart.chat — interface in the Braun manner.
 * Less, but better: one typeface, hairlines instead of shadows, a warm off-white
 * ground, and colour used only where it carries meaning.
 *   orange = the one thing to press, and what is yours
 *   green  = on / live
 *   red    = destructive or about to expire
 */
:root {
  --bg: #ECE9E3;
  --panel: #F6F4EF;
  --panel-2: #E4E0D8;
  --line: #D3CEC4;
  --line-strong: #B5AFA3;
  --text: #1A1A19;
  --muted: #66625A;
  --accent: #E8500A;
  --accent-ink: #1A1A19;
  --key: #1A1A19;          /* primary button body */
  --key-hover: #33322F;
  --key-text: #F6F4EF;
  --ok: #4F7F35;
  --danger: #B8321F;
  --danger-soft: #F1DDD7;
  --radius: 3px;
  --meta-col: 9.5rem;
  --gutter: 1.5rem;
  --font: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
}
body.night {
  --bg: #151514;
  --panel: #1D1D1C;
  --panel-2: #272726;
  --line: #333331;
  --line-strong: #4D4C48;
  --text: #ECE9E2;
  --muted: #9B978F;
  --accent: #FF6A1A;
  --accent-ink: #151514;
  --key: #ECE9E2;
  --key-hover: #FFFFFF;
  --key-text: #151514;
  --ok: #7DB55A;
  --danger: #F0705F;
  --danger-soft: #3A211D;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  color-scheme: light;
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

/* ---------- type ---------- */
h1 { font-weight: 500; font-size: 1.6rem; line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .6rem; }
h2 { font-weight: 500; font-size: 1.25rem; margin: .5rem 0; }
h3, label, legend, .ttl-label, .badge, .how summary {
  font-size: .7rem; font-weight: 500; text-transform: uppercase; letter-spacing: .09em; color: var(--muted);
}
h3 { margin: 0 0 1rem; }
p { margin: .5rem 0; }
.lead { color: var(--muted); max-width: 46ch; }
.muted { color: var(--muted); }
.small-text { font-size: .8rem; }
code { font: .85em/1 ui-monospace, Menlo, Consolas, monospace; background: var(--panel-2); padding: .15em .35em; border-radius: 2px; }
a { color: var(--text); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--accent); }

/* ---------- cards ---------- */
.view { min-height: 100%; }
.card {
  max-width: 540px;
  margin: 8vh auto;
  padding: 2.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card.center { text-align: center; }
.card.center .lead { margin-inline: auto; }
.row { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; }

/* ---------- forms ---------- */
label { display: block; margin: 1.5rem 0 .45rem; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: .65rem .8rem;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; white-space: nowrap; }
textarea:focus, select:focus, input:not([type="radio"]):not([type="checkbox"]):focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
input[type="radio"], input[type="checkbox"] { outline: none; accent-color: var(--ok); width: 15px; height: 15px; margin: 0; }
input[type="radio"]:focus-visible { outline: 2px solid var(--ok); outline-offset: 2px; border-radius: 50%; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--ok); outline-offset: 2px; }
fieldset { border: 0; padding: 0; margin: 2rem 0 0; }
legend { padding: 0; margin-bottom: .5rem; }

/* password fields: an eye at the right edge shows what is being typed */
.pw-field { position: relative; }
.pw-field input { padding-right: 2.9rem; }
.pw-toggle {
  position: absolute; top: 1px; right: 1px; bottom: 1px; width: 2.7rem; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: var(--radius); cursor: pointer;
}
.pw-toggle .px { display: block; width: 20px; height: 20px; background: var(--muted); --icon: url("/icons/eye.svg?v=Kur1IfV4kO"); -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.pw-toggle:hover .px { background: var(--text); }
.pw-toggle[aria-pressed="true"] .px { --icon: url("/icons/eye-off.svg?v=Kur1IfV4kO"); background: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

.human-check { margin-top: 1.5rem; }
.human-label { display: block; margin-bottom: .45rem; font-size: .7rem; font-weight: 500; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
#turnstile-box { min-height: 65px; }
.back-link { margin-top: 1.5rem; }

/* access modes: a plain list divided by hairlines, the chosen row marked in orange */
.option {
  display: flex; gap: .9rem; align-items: flex-start;
  padding: .85rem 0 .85rem .9rem; margin: 0;
  border-top: 1px solid var(--line); border-left: 2px solid transparent;
  cursor: pointer; text-transform: none; letter-spacing: 0; font-size: 1rem; color: var(--text); font-weight: 400;
}
.option:last-of-type { border-bottom: 1px solid var(--line); }
.option:has(input:checked) { border-left-color: var(--accent); background: var(--bg); }
.option input { margin-top: .25rem; flex: none; }
.option strong { display: block; font-weight: 500; }
.option small { color: var(--muted); font-size: .85rem; }

/* ---------- buttons ---------- */
button, .button {
  display: inline-block; cursor: pointer; font: inherit; font-size: .87rem; font-weight: 500;
  padding: .6rem 1.1rem; border-radius: var(--radius); border: 1px solid transparent;
  text-decoration: none; line-height: 1.2; letter-spacing: .01em;
  transition: background-color .12s, border-color .12s;
}
button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, .button.primary { background: var(--key); color: var(--key-text); border-color: var(--key); }
button.primary:hover, .button.primary:hover { background: var(--key-hover); border-color: var(--key-hover); }
.card form > button.primary { width: 100%; margin-top: 2rem; padding: .8rem 1.1rem; }
button.secondary { background: transparent; color: var(--text); border-color: var(--line-strong); }
button.secondary:hover { background: var(--panel-2); border-color: var(--text); }
button.danger { background: transparent; color: var(--danger); border-color: var(--line-strong); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.small { padding: .42rem .75rem; font-size: .8rem; }
button:disabled { opacity: .45; cursor: default; }
.error { color: var(--danger); font-weight: 500; font-size: .87rem; }

.how { margin-top: 2.5rem; padding-top: 1.1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .87rem; }
.how summary { cursor: pointer; }
.how summary:hover { color: var(--text); }
.how ul { padding-left: 1.1rem; margin: 1rem 0 0; }
.how li { margin: .55rem 0; }

/* ---------- chat frame ---------- */
.chat { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 58px;
  padding: .5rem 72px .5rem var(--gutter);
  background: var(--panel); border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: .65rem; }
.topbar-left strong { font-weight: 700; font-size: 1rem; letter-spacing: -.01em; margin-right: .35rem; }
.topbar-right { display: flex; gap: .4rem; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.live { background: var(--ok); }
.badge { font-size: .65rem; padding: .2rem .5rem; border: 1px solid var(--line); border-radius: 2px; }

.chat-body { display: flex; flex: 1; min-height: 0; }
.messages-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 1rem var(--gutter) 1.5rem; display: flex; flex-direction: column; }
.side { width: 300px; padding: 1.5rem var(--gutter); background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; }
.side .switch {
  display: flex; gap: .7rem; align-items: flex-start; margin: 0; padding: .7rem 0; border-top: 1px solid var(--line);
  cursor: pointer; text-transform: none; letter-spacing: 0; font-size: .87rem; font-weight: 400; color: var(--text);
}
.side .switch input { margin-top: .2rem; flex: none; }
.side .small-text { border-top: 1px solid var(--line); padding-top: .8rem; margin: 0 0 .8rem; }
.member-list { list-style: none; padding: 0; margin: 0; }
.member-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem 0; border-top: 1px solid var(--line); font-size: .93rem; }
.member-list .tag { font-size: .62rem; font-weight: 500; color: var(--muted); margin-left: .5rem; letter-spacing: .09em; }

.pending-bar { padding: .7rem var(--gutter); background: var(--panel); border-bottom: 1px solid var(--line); border-left: 2px solid var(--accent); display: flex; flex-direction: column; gap: .5rem; }
.pending-item { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pending-item strong { flex: 1; font-weight: 500; }

/* ---------- messages: a ruled log, who and when on the left, what on the right ---------- */
.msg {
  display: grid; grid-template-columns: var(--meta-col) minmax(0, 1fr); column-gap: var(--gutter);
  padding: .75rem 0; border-top: 1px solid var(--line);
  word-wrap: break-word; overflow-wrap: anywhere;
}
.msg:first-child { border-top: 0; }
.msg .meta { font-size: .75rem; line-height: 1.5rem; color: var(--muted); }
.msg.mine .meta { color: var(--text); }
.msg.mine .meta::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: .45rem; vertical-align: .08em; }
.msg .ttl { display: block; font-size: .7rem; line-height: 1.2; color: var(--muted); }
.msg .ttl.soon { color: var(--danger); font-weight: 500; }
.msg .text { white-space: pre-wrap; max-width: 68ch; }
.msg.system { display: block; padding: .55rem 0 .55rem calc(var(--meta-col) + var(--gutter)); color: var(--muted); font-size: .8rem; }

/* screen guard */
body.guard-copy .messages { user-select: none; -webkit-user-select: none; }
body.guard-reveal .msg:not(.system) .text,
body.guard-reveal .msg:not(.system) .file { filter: blur(7px); transition: filter .15s; }
body.guard-reveal .msg:not(.system):hover .text,
body.guard-reveal .msg:not(.system):hover .file,
body.guard-reveal .msg.revealed .text,
body.guard-reveal .msg.revealed .file { filter: none; }
body.guard-reveal .msg:not(.system) { cursor: pointer; }

/* attachments */
.file { display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; }
.file-name { font-weight: 500; word-break: break-all; }
.file-status, .file-expired { font-size: .8rem; color: var(--muted); }
.file-preview { max-width: min(100%, 480px); max-height: 360px; border-radius: 2px; border: 1px solid var(--line); display: block; object-fit: contain; background: var(--panel-2); cursor: zoom-in; }
.file-preview:hover { border-color: var(--line-strong); }
.file-preview:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* full-size viewer */
#lightbox {
  position: fixed; inset: 0; z-index: 900; background: rgba(12, 12, 11, .94);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem;
  padding: 4rem 2rem 2rem; cursor: zoom-out;
}
#lightbox-img { max-width: 100%; max-height: calc(100% - 2.5rem); object-fit: contain; border-radius: 2px; background: #1D1D1C; user-select: none; -webkit-user-select: none; min-height: 0; }
.lightbox-caption { margin: 0; font-size: .8rem; color: #9B978F; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lightbox-close { position: absolute; top: 12px; right: 14px; color: #ECE9E2; border-color: #4D4C48; background: transparent; }
#lightbox-close:hover { background: #272726; border-color: #ECE9E2; }
.file-download { font-size: .8rem; font-weight: 500; }
#view-chat.dragging .messages { outline: 1px dashed var(--accent); outline-offset: -10px; }

/* ---------- composer ---------- */
.shutdown-bar { margin: 0; padding: .6rem var(--gutter); font-size: .87rem; font-weight: 500; color: var(--text); background: var(--panel); border-top: 1px solid var(--line); border-left: 2px solid var(--danger); }
.panic-hint { margin: 0; padding: .5rem var(--gutter); font-size: .8rem; font-weight: 500; color: var(--danger); background: var(--danger-soft); border-top: 1px solid var(--line); }
.send-form { display: flex; gap: .6rem; padding: .9rem var(--gutter); border-top: 1px solid var(--line); background: var(--panel); align-items: flex-end; }
.send-form textarea { flex: 1; resize: none; min-height: 44px; padding-top: .7rem; padding-bottom: .7rem; max-height: 10rem; overflow-y: auto; line-height: 1.4; display: block; }
.send-form button { margin: 0; }
.send-form button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); height: 44px; padding: 0 1.4rem; }
.send-form button.primary:hover { filter: brightness(1.07); }
.ttl-wrap { display: flex; flex-direction: column; gap: .25rem; margin: 0; }
.ttl-label { font-size: .62rem; }
.ttl-wrap select { width: auto; font-size: .8rem; padding: .3rem .4rem; height: 28px; cursor: pointer; background: var(--bg); }

/* ---------- screen-guard curtain ---------- */
#curtain {
  position: fixed; inset: 0; z-index: 1000; background: #000; color: #ECE9E2;
  display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer;
}
#curtain .muted { color: #9B978F; }
.curtain-icon { margin-bottom: 1rem; line-height: 0; }

/* ---------- mark ---------- */
.brand { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.25rem; }
.brand h1 { margin: 0; font-weight: 700; font-size: 1.7rem; letter-spacing: -.025em; }
.mark-dot { color: var(--accent); }
.brand.compact { gap: .55rem; margin-bottom: 2rem; }
.brand.compact .wordmark { font-weight: 700; font-size: 1rem; letter-spacing: -.01em; color: var(--text); }
.brand.centered { justify-content: center; }

.logo-anim {
  display: block;
  width: 64px; height: 64px; flex: none;
  background: url("/logo_sheet.png?v=Kur1IfV4kO") 0 0 no-repeat;
  image-rendering: pixelated;
  animation: tailbob 1.10s step-end infinite;
}
@keyframes tailbob {
  0%    { background-position: 0 0; }      /* neutral, holds 0.80s */
  72.7% { background-position: -64px 0; }  /* dip, 0.08s */
  80.0% { background-position: -128px 0; } /* low, 0.14s */
  92.7% { background-position: -192px 0; } /* back, 0.08s */
}
@media (prefers-reduced-motion: reduce) { .logo-anim { animation: none; } }
/* the sprite is always 64px and scaled by whole numbers or exact halves */
.logo-wrap { width: 32px; height: 32px; overflow: hidden; display: inline-block; flex: none; }
.logo-wrap .logo-anim { transform: scale(.5); transform-origin: top left; }
.logo-wrap.x2 { width: 64px; height: 64px; }
.logo-wrap.x2 .logo-anim { transform: none; }
/* chat page: the header bird only bobs while hovered */
#view-chat .logo-anim { animation: none; }
#view-chat .logo-wrap:hover .logo-anim { animation: tailbob 1.10s step-end infinite; }
/* the charcoal bird would vanish on a dark page, so at night he sits on a light tile */
body.night .logo-wrap { background: #ECE9E2; border-radius: 2px; }

/* ---------- round controls ---------- */
.icon-btn {
  width: 44px; height: 44px; padding: 0; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 50%; cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); border-color: var(--text); }
/* line icons are masks, so they take their colour from the theme */
.icon-btn .px { display: block; width: 20px; height: 20px; background: var(--text); -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
#attach-button .px { --icon: url("/icons/folder.svg?v=Kur1IfV4kO"); }
#theme-toggle .px { --icon: url("/icons/moon.svg?v=Kur1IfV4kO"); }
body.night #theme-toggle .px { --icon: url("/icons/sun.svg?v=Kur1IfV4kO"); }
.theme-toggle { position: fixed; top: 7px; right: 14px; z-index: 50; }

/* ---------- status pictures ---------- */
.px-flame, .px-lock, .px-hourglass {
  display: inline-block; width: 48px; height: 48px; background: var(--text);
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.px-flame { --icon: url("/icons/flame.svg?v=Kur1IfV4kO"); }
.px-lock { --icon: url("/icons/lock.svg?v=Kur1IfV4kO"); background: #ECE9E2; }
.px-hourglass { --icon: url("/icons/hourglass.svg?v=Kur1IfV4kO"); display: block; margin: 0 auto 1.25rem; animation: turn 2.4s cubic-bezier(.6, 0, .3, 1) infinite; }
@keyframes turn { 0%, 55% { transform: rotate(0); } 100% { transform: rotate(180deg); } }
@media (prefers-reduced-motion: reduce) { .px-hourglass { animation: none; } }

/* ---------- narrow windows ---------- */
@media (max-width: 720px) {
  :root { --gutter: 1rem; }
  .card { margin: 0; border: 0; border-radius: 0; min-height: 100vh; padding: 4.5rem 1.5rem 2rem; }
  .side { position: absolute; right: 0; top: 0; bottom: 0; z-index: 10; }
  .chat-body { position: relative; }
  .msg { grid-template-columns: minmax(0, 1fr); row-gap: .1rem; }
  .msg .ttl { display: inline; margin-left: .6rem; }
  .msg.system { padding-left: 0; }
}
