/* =========================================================================
   SHARE — Editorial paper aesthetic, sibling to admin.css
   Same trio: Fraunces (display), Newsreader (body), JetBrains Mono (data).
   Same palette: cream paper + sepia ink + terracotta accent.
   Layout keeps interactive panel structure (dashboard cards) for the dynamic
   guest view; admin remains text-heavy.
   ========================================================================= */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT,WONK@0,9..144,300..900,0..100,0..1;1,9..144,300..900,0..100,0..1&family=JetBrains+Mono:ital,wght@0,400..700;1,400..700&family=Newsreader:ital,opsz,wght@0,6..72,300..700;1,6..72,300..700&display=swap");

:root {
  --paper:        #f5f0e6;
  --paper-warm:   #fbf7ee;
  --paper-deeper: #ece4d2;
  --ink:          #1c1612;
  --ink-soft:     #443a2f;
  --muted:        #7a6f60;
  --hairline:     #c8bca4;
  --border:       #d6cab2;
  --seal:         #b8431f;
  --seal-dark:    #8a3318;
  --sage:         #3f5c3b;
  --mustard:      #9c731b;

  --serif-display: "Fraunces", "Georgia", serif;
  --serif-body:    "Newsreader", "Georgia", serif;
  --mono:          "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  font-family: var(--serif-body);
  font-size: 16px;
  font-variation-settings: "opsz" 14;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top left, rgba(184,67,31,0.04), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(60,40,20,0.05), transparent 60%),
    var(--paper);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  min-height: 100vh;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.4 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.18'/></svg>");
  mix-blend-mode: multiply;
  opacity: 0.5;
  z-index: 100;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 56px 48px 96px;
  position: relative;
  z-index: 1;
}

/* ── Masthead ─────────────────────────────────────────────────────────── */

.masthead {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 36px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.masthead-brand { color: var(--ink); font-weight: 600; display: inline-flex; align-items: center; gap: 0.5em; }
/* Claude avatar (raster webp from lobe-icons). Sized 1.4em to read clearly
   next to the brand text without dominating. border-radius rounds the
   sharp corners of the source image. */
.brand-logo {
  width: 1.4em;
  height: 1.4em;
  flex: none;
  border-radius: 4px;
  vertical-align: middle;
}

/* ── Type primitives ──────────────────────────────────────────────────── */

h1 {
  font-family: var(--serif-display);
  font-weight: 500;
  font-variation-settings: "opsz" 96, "SOFT" 30;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 0.98;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
  color: var(--ink);
  animation: rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
h1 em {
  font-style: italic;
  color: var(--seal);
  font-variation-settings: "opsz" 144, "WONK" 1, "SOFT" 80;
}

h2 {
  font-family: var(--serif-display);
  font-weight: 400;
  font-variation-settings: "opsz" 28;
  font-size: 20px;
  letter-spacing: -0.005em;
  margin: 28px 0 12px;
  display: flex; align-items: baseline; gap: 14px;
  color: var(--ink);
}
h2::before {
  content: attr(data-section);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--seal);
  text-transform: uppercase;
  transform: translateY(-2px);
}

a {
  color: var(--seal);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  transition: color 0.2s, border-color 0.2s;
}
a:hover { color: var(--seal-dark); border-color: var(--seal-dark); }

p { margin: 0 0 12px; }
small, .small { font-size: 12px; color: var(--muted); }

code, .mono {
  font-family: var(--mono);
  font-size: 0.9em;
  letter-spacing: -0.01em;
  background: var(--paper-deeper);
  padding: 1px 6px;
  border-radius: 2px;
  color: var(--ink);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── Card entry (login) ───────────────────────────────────────────────── */

.card-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 32px;
}
.card-entry h1 { text-align: center; }
.card-entry .intro {
  font-size: 17px;
  color: var(--ink-soft);
  font-style: italic;
  max-width: 480px;
  margin: 8px 0 32px;
}
.card-entry form {
  width: min(560px, 100%);
  background: var(--paper-warm);
  border: 1px solid var(--ink);
  padding: 36px 44px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  text-align: left;
  position: relative;
}
.card-entry .back-to-home {
  margin-top: 28px;
  font-size: 14px;
  color: var(--ink-soft);
}
.card-entry .back-to-home a {
  color: var(--accent, #c5453f);
  text-decoration: none;
}
.card-entry .back-to-home a:hover { text-decoration: underline; }
.card-entry form::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid var(--ink);
  opacity: 0.18;
  pointer-events: none;
}

form label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex; flex-direction: column; gap: 6px;
}
form input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.02em;
  padding: 6px 0 8px;
  transition: border-color 0.2s;
}
form input:focus {
  outline: none;
  border-bottom-width: 2px;
  border-bottom-color: var(--seal);
  padding-bottom: 7px;
}
form input::placeholder { color: var(--hairline); font-style: italic; }

/* ── Buttons ──────────────────────────────────────────────────────────── */

button {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  background: var(--ink);
  color: var(--paper-warm);
  border: 1px solid var(--ink);
  padding: 10px 18px;
  cursor: pointer;
  transition: all 0.18s;
  margin: 4px 4px 4px 0;
}
button:hover { background: var(--seal); border-color: var(--seal); }
button:active { transform: translateY(1px); }
button[data-op="stop"] { background: var(--seal-dark); border-color: var(--seal-dark); }
button[data-op="stop"]:hover { background: #6e2510; border-color: #6e2510; }
button[data-op="reboot"] { background: var(--mustard); border-color: var(--mustard); }
button[data-op="reboot"]:hover { background: #7c5a17; border-color: #7c5a17; }

/* ── Share dashboard header ──────────────────────────────────────────── */

.share-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 12px;
  gap: 16px;
}
.share-header h1 { margin: 0; }
.share-header .room-no {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
  text-align: right;
}
.share-header .room-no form { display: inline; }
.share-header .room-no button {
  background: transparent;
  color: var(--ink);
  margin-top: 8px;
  padding: 6px 14px;
}
.share-header .room-no button:hover { background: var(--ink); color: var(--paper-warm); }

/* ── Panels (dashboard cards) ────────────────────────────────────────── */

section.panel {
  background: var(--paper-warm);
  border: 1px solid var(--ink);
  padding: 26px 30px;
  margin: 18px 0;
  position: relative;
}
section.panel::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid var(--ink);
  opacity: 0.12;
  pointer-events: none;
}

section.panel dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 14px 32px;
  margin: 0;
  align-items: baseline;
  position: relative;
  z-index: 1;
}
section.panel dt {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
section.panel dd {
  margin: 0;
  font-family: var(--serif-display);
  font-variation-settings: "opsz" 36;
  font-size: 22px;
  color: var(--ink);
}
section.panel dd .mono-val {
  font-family: var(--mono);
  font-size: 17px;
  color: var(--ink-soft);
}
section.panel dd .state {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 3px 9px;
  border: 1px solid currentColor;
}
section.panel dd .state--running { color: var(--sage); }
section.panel dd .state--stopped { color: var(--seal-dark); }
section.panel dd .state--pending { color: var(--mustard); }
/* Transition states (synthesized client-side between click and DO catching up).
   Pulses opacity so the user can see "yes, something is happening." */
section.panel dd .state--transit {
  color: var(--mustard);
  animation: state-pulse 1.2s ease-in-out infinite;
}
@keyframes state-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}
section.panel dd .cost-line {
  font-family: var(--serif-display);
  font-variation-settings: "opsz" 32;
  font-size: 20px;
}
section.panel dd .cost-total {
  font-style: italic;
  color: var(--seal);
  font-variation-settings: "opsz" 36, "WONK" 1, "SOFT" 50;
}

.ops-row { display: flex; gap: 10px; flex-wrap: wrap; }

select {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--paper-warm);
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 6px 10px;
}

canvas {
  max-width: 100%;
  background: var(--paper-warm);
  padding: 14px;
  border: 1px solid var(--hairline);
  margin: 8px 0;
}

/* ── Flashes ──────────────────────────────────────────────────────────── */

.flashes { list-style: none; padding: 0; margin: 0 0 24px; }
.flash {
  padding: 12px 18px;
  border-left: 4px solid;
  font-family: var(--serif-body);
  background: var(--paper-warm);
  animation: fade-in 0.4s both;
}
.flash--error { border-color: var(--seal-dark); color: var(--seal-dark); }
.flash--info  { border-color: var(--ink); color: var(--ink); }

/* ── Footer ───────────────────────────────────────────────────────────── */

footer.colophon {
  margin-top: 64px;
  padding-top: 16px;
  border-top: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

/* ── Stagger animations ──────────────────────────────────────────────── */

.container > .masthead          { animation: fade-in 0.6s 0s both; }
.container > .share-header,
.container > .card-entry        { animation: rise 0.7s 0.1s cubic-bezier(0.16,1,0.3,1) both; }
.container > section.panel:nth-of-type(1) { animation: rise 0.8s 0.2s cubic-bezier(0.16,1,0.3,1) both; }
.container > section.panel:nth-of-type(2) { animation: rise 0.8s 0.3s cubic-bezier(0.16,1,0.3,1) both; }
.container > section.panel:nth-of-type(3) { animation: rise 0.8s 0.4s cubic-bezier(0.16,1,0.3,1) both; }
.container > section.panel:nth-of-type(4) { animation: rise 0.8s 0.5s cubic-bezier(0.16,1,0.3,1) both; }

@media (max-width: 720px) {
  .container { padding: 32px 22px 56px; }
  section.panel { padding: 20px; }
  section.panel dl { grid-template-columns: 1fr; gap: 4px 0; }
  section.panel dt { margin-top: 12px; }
  .share-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .share-header .room-no { text-align: left; }
}

/* ── §II 操作栏 + Mac 风格终端 ──────────────────────────────────────────── */

/* Wide screens: 2-column grid — buttons stack vertically on the left,
   terminal fills the right column. The left column is sized to fit the
   widest button label without growing arbitrarily. */
.ops-mac-row {
  display: grid;
  grid-template-columns: minmax(180px, 220px) 1fr;
  gap: 20px;
  align-items: stretch;
}
.ops-mac-row .ops-row {
  display: flex;
  flex-direction: column;       /* buttons stack vertically */
  gap: 10px;
  flex-wrap: nowrap;
  align-content: flex-start;
}
.ops-mac-row .ops-row > button {
  width: 100%;                  /* fill the left column */
  margin: 0;
}

/* Narrow screens / mobile: fall back to vertical stacking — buttons
   above terminal, terminal full width, buttons go back to horizontal row. */
@media (max-width: 640px) {
  .ops-mac-row {
    grid-template-columns: 1fr;
  }
  .ops-mac-row .ops-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .ops-mac-row .ops-row > button {
    width: auto;
  }
}

.mac-window {
  background: #1e1e1e;
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;                 /* allow grid cell to shrink */
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 10px 28px rgba(40, 28, 18, 0.32),
    0 2px 6px rgba(40, 28, 18, 0.18);
  border: 1px solid #0b0b0b;
}
.mac-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #3c3c3e 0%, #2d2d2f 100%);
  padding: 8px 12px;
  border-bottom: 1px solid #0b0b0b;
  position: relative;
}
.mac-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.4) inset;
}
.mac-dot--red    { background: #ff5f57; }
.mac-dot--yellow { background: #febc2e; }
.mac-dot--green  { background: #28c840; }
.mac-titletext {
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #a8a8a8;
  letter-spacing: 0.04em;
}
.mac-copy {
  background: transparent;
  color: #888;
  border: none;
  padding: 2px 6px !important;
  font-family: var(--mono);
  font-size: 11px !important;
  letter-spacing: 0.04em !important;
  text-transform: none;
  cursor: pointer;
  margin: 0 !important;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
}
.mac-copy:hover {
  background: transparent;
  color: #fff;
  opacity: 1;
}

.mac-code {
  margin: 0;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  background: #1e1e1e;
  color: #d4d4d4;
  white-space: pre;
  overflow-x: auto;
  border: none;
  /* override the global canvas-like styling */
}
.mac-code .m-c { color: #6a9955; font-style: italic; }   /* comment */
.mac-code .m-v { color: #ce9178; }                       /* variable (filename / ip) */
.mac-code .m-u { color: #4ec9b0; }                       /* username */

/* Chart container — Chart.js fills 100% of this box at the right DPR */
.chart-box {
  position: relative;
  width: 100%;
  height: 240px;
  margin-bottom: 18px;
}
.chart-box > canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ── § III oneliner terminal (full width, not the §II grid layout) ─────── */
.mac-window--solo {
  display: block;
  width: 100%;
  max-width: none;
}
/* The &&-chain is intentionally one long line; let it scroll horizontally
   instead of wrapping (wrap mid-command would visually break the chain). */
.mac-code--oneliner {
  white-space: pre;
  overflow-x: auto;
}

/* ── § IV Claude Code cheatsheet ───────────────────────────────────────── */
.cheatsheet {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.cheatsheet-row {
  display: grid;
  grid-template-columns: minmax(220px, 38%) 1fr;
  gap: 18px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px dashed var(--hairline);
}
.cheatsheet-row:last-child { border-bottom: none; }
.cheatsheet-cmd {
  font-family: var(--mono);
  font-size: 13px;
}
.cheatsheet-cmd code {
  background: var(--paper-deeper);
  color: var(--ink);
  padding: 4px 10px;
  border: 1px solid var(--hairline);
  display: inline-block;
  word-break: break-all;
}
.cheatsheet-desc {
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.cheatsheet-desc .mono { font-family: var(--mono); font-size: 12px; }

@media (max-width: 640px) {
  .cheatsheet-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* Wide cheatsheet row — for commands whose prompt is long enough to need
   the full column width (e.g. /statusline with an embedded natural-language
   prompt the user just pastes verbatim). */
.cheatsheet-row--wide {
  grid-template-columns: 1fr;
}
.cheatsheet-cmd--wide {
  position: relative;
  width: 100%;
  /* Grid items default to min-width: min-content, which makes them expand
     to fit any non-wrapping child. We need min-width: 0 here so the child
     <code> with white-space: pre can actually overflow-x: auto inside the
     column instead of pushing the whole grid wider. */
  min-width: 0;
}
.cheatsheet-cmd-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.cheatsheet-cmd--wide > code {
  display: block;
  background: var(--paper-deeper);
  color: var(--ink);
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  /* Match .mac-code--oneliner: never wrap, horizontal scroll on overflow.
     The /statusline prompt is one long sentence that reads ugly when it
     reflows across 6+ lines. Single-line + horizontal scroll keeps the
     visual length constant. */
  white-space: pre;
  overflow-x: auto;
}
.cheatsheet-copy {
  position: absolute;
  right: 8px;
  top: 28px;   /* below the cheatsheet-cmd-label line */
}

/* ── aTimes download button row ───────────────────────────────────────── */
.dl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.dl-btn {
  display: inline-block;
  padding: 10px 18px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  background: var(--ink);
  color: var(--paper-warm) !important;
  border: 1px solid var(--ink) !important;
  text-decoration: none !important;
  transition: all 0.18s;
}
.dl-btn:hover {
  background: var(--seal);
  border-color: var(--seal) !important;
  color: var(--paper-warm) !important;
}
.dl-btn--ghost {
  background: transparent;
  color: var(--ink) !important;
}
.dl-btn--ghost:hover {
  background: var(--paper-deeper);
  color: var(--seal) !important;
}

/* ── § III SSH relay badge ─────────────────────────────────────────────── */
.relay-badge {
  display: inline-block;
  margin-left: 12px;
  padding: 3px 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: none;
  vertical-align: middle;
  border: 1px solid currentColor;
  border-radius: 2px;
  font-weight: normal;
}
.relay-badge--on {
  color: var(--sage);
  background: rgba(63, 92, 59, 0.05);
}
.relay-badge--off {
  color: var(--seal-dark);
  background: rgba(184, 67, 31, 0.05);
}
.relay-badge--unknown {
  color: var(--muted);
}

