:root {
  --bg: #f6f4ef;
  --panel: #fffefb;
  --ink: #1b1a17;
  --muted: #6a675f;
  --line: #e1ddd3;
  --accent: #1f3a5f;
  --accent-ink: #fff;
  --soft: #ebe7dd;
  --danger: #a3261c;
  --radius: 8px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
#app { min-height: 100%; }
a { color: inherit; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 650; margin: 28px 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.boot { padding: 20vh 0; text-align: center; color: var(--muted); }

button, .btn {
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
button:hover, .btn:hover { background: var(--soft); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { background: #172c49; }
button.danger { color: var(--danger); }
button.quiet { border-color: transparent; background: none; padding: 5px 8px; color: var(--muted); }
button.quiet:hover { background: var(--soft); color: var(--ink); }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; min-width: 0;
}
textarea { width: 100%; min-height: 220px; font: 13px/1.5 ui-monospace, Consolas, monospace; resize: vertical; }
label { display: block; font-weight: 550; margin-bottom: 4px; }
.field { margin-bottom: 18px; }
.field input[type=text], .field select { width: 100%; max-width: 440px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.error { color: var(--danger); margin: 10px 0; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--soft); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; padding: 2px 8px 16px; text-decoration: none; }
.brand img { width: 24px; height: 24px; }
.side .primary { margin: 0 4px 14px; }
.side button.quiet { justify-content: flex-start; padding: 6px 10px; }
.side a.nav { display: block; padding: 6px 10px; border-radius: 6px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side a.nav:hover { background: #dfdacd; }
.side a.nav.on { background: var(--panel); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.side .label { font-size: 12px; font-weight: 650; color: var(--muted); padding: 16px 10px 4px; text-transform: uppercase; letter-spacing: .05em; }
.side .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.side .foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 32px 40px 64px; max-width: 1040px; width: 100%; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }

.invite { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }

/* ---- list ---- */
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: grid; grid-template-columns: 64px 1fr auto auto; gap: 14px; align-items: center; padding: 11px 16px; text-decoration: none; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item:hover { background: #faf8f3; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .when { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kind { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; text-align: center; padding: 3px 0; border-radius: 4px; background: var(--soft); color: #4a4740; }
.kind.html { background: #dfe8f3; color: #1f3a5f; }
.kind.doc { background: #dde9f7; color: #1c4a8a; }
.kind.sheet { background: #dcefe0; color: #1d6034; }
.kind.slides { background: #f8e3d3; color: #97410f; }
.kind.diagram { background: #ebe0f5; color: #5b2a8c; }
.kind.pdf { background: #f6dcda; color: #8e231a; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.public { border-color: #b7cfae; color: #2c5b1f; background: #eef5ea; }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* ---- new ---- */
.drop { border: 1.5px dashed #c5c0b3; border-radius: var(--radius); padding: 26px; text-align: center; background: var(--panel); }
.drop.over { border-color: var(--accent); background: #eef2f7; }
.files { margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); max-height: 160px; overflow: auto; text-align: left; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-bottom: 12px; }
.seg button { border: 0; border-radius: 0; background: var(--panel); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* ---- viewer ---- */
.viewer { display: flex; flex-direction: column; height: 100vh; }
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.bar .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bar .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.bar select { padding: 5px 8px; }
.bar .kind { padding: 3px 8px; flex: none; }
.stage { flex: 1; display: flex; min-height: 0; }
.stage iframe { flex: 1; min-width: 0; border: 0; background: #fff; }
button[aria-pressed=true] { background: var(--soft); box-shadow: inset 0 0 0 1px #c9c4b6; }
.comments { width: 340px; flex: none; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 16px; }
.comments h2 { margin-top: 0; }
.composer { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.composer textarea { min-height: 64px; font: inherit; }
.thread .composer textarea { min-height: 38px; }
.threads { margin-top: 16px; }
.thread { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; background: #fff; }
.thread.resolved { opacity: .7; }
.comment { margin-bottom: 10px; }
.comment + .comment { padding-left: 12px; border-left: 2px solid var(--line); }
.comment .by { font-size: 13px; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.comment .by button { margin-left: auto; font-size: 12px; }
.comment .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.old { background: #fff7d6; border-bottom: 1px solid #ead9a0; padding: 6px 14px; font-size: 13px; display: flex; gap: 12px; align-items: center; }

/* ---- dialog ---- */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: min(520px, calc(100vw - 32px)); color: inherit; background: var(--panel); box-shadow: 0 18px 50px #0003; }
dialog::backdrop { background: #1b1a1755; }
dialog h1 { font-size: 18px; margin-bottom: 14px; }
.people { list-style: none; margin: 12px 0 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }
.people .email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 20px; }

/* ---- landing ---- */
.landing { max-width: 560px; margin: 0 auto; padding: 18vh 24px; }
.landing h1 { font-size: 34px; line-height: 1.15; margin-bottom: 14px; }
.landing p { color: var(--muted); font-size: 17px; margin-bottom: 24px; }

table.members { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.members td { padding: 9px 14px; border-top: 1px solid var(--line); }
table.members tr:first-child td { border-top: 0; }
table.members td:last-child { text-align: right; white-space: nowrap; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .side .foot { margin-top: 12px; }
  .main { padding: 22px 16px 48px; }
  .item { grid-template-columns: 56px 1fr auto; }
  .item .when { display: none; }
  .bar { flex-wrap: wrap; }
  .bar .meta { display: none; }
  .stage { flex-direction: column; }
  .comments { width: auto; max-height: 45vh; border-left: 0; border-top: 1px solid var(--line); }
}
