/* RnD Daily — archive shell (Internal / Confidential)
 * Sidebar of editions + topic filters, latest edition framed in the main pane.
 * Edition bodies keep their own Kasane styling; tag colours below mirror theirs.
 */
:root {
  --paper: #f5efe3;
  --paper-raised: #faf6ee;
  --paper-sunk: #efe7d8;
  --ink: #29242a;
  --ink-muted: rgba(41, 36, 42, 0.68);
  --ink-faint: rgba(41, 36, 42, 0.45);
  --accent: #825dad;
  --accent-ink: #6a4791;
  --accent-soft: rgba(130, 93, 173, 0.12);
  --rule: rgba(41, 36, 42, 0.12);
  --shadow: 0 8px 24px rgba(41, 36, 42, 0.1);
  --side-w: 320px;
  --bar-h: 48px;
  --radius: 8px;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Hiragino Mincho ProN", "Noto Serif JP", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1f1b1e;
    --paper-raised: #272226;
    --paper-sunk: #18151a;
    --ink: #eee6d8;
    --ink-muted: rgba(238, 230, 216, 0.7);
    --ink-faint: rgba(238, 230, 216, 0.45);
    --accent: #b394d9;
    --accent-ink: #c9b0ea;
    --accent-soft: rgba(179, 148, 217, 0.16);
    --rule: rgba(238, 230, 216, 0.12);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

/* Topic colours (same hues as the editions' --t-* tokens) */
.t-models { --c: #4f46e5; }
.t-discord { --c: #7c3aed; }
.t-social { --c: #0284c7; }
.t-industry { --c: #d97706; }
.t-team { --c: #0f9d9a; }
.t-experiments { --c: #e8452c; }

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.mark {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

/* ---------- layout ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.shell.collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.shell.collapsed .side {
  visibility: hidden;
}

/* ---------- sidebar ---------- */

.side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--paper-raised);
  border-right: 1px solid var(--rule);
}

.side-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--rule);
}

.brand {
  margin: 6px 0 2px;
  font: 600 1.6rem/1.1 var(--font);
  letter-spacing: -0.02em;
}

.brand a {
  color: var(--ink);
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.side-sub {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.filters {
  padding: 12px 20px 10px;
  border-bottom: 1px solid var(--rule);
}

.filters-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.linkish {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.linkish:hover {
  text-decoration: underline;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.tag i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
}

.tag .n {
  color: var(--ink-faint);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.tag:hover {
  border-color: var(--c);
}

.tag[aria-pressed="true"] {
  background: var(--c);
  border-color: var(--c);
  color: #fff;
}

.tag[aria-pressed="true"] i {
  background: #fff;
}

.tag[aria-pressed="true"] .n {
  color: rgba(255, 255, 255, 0.8);
}

.tag:disabled {
  opacity: 0.45;
  cursor: default;
}

.filters-note {
  margin: 8px 0 0;
  color: var(--ink-faint);
  font-size: 0.75rem;
}

.editions {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 10px 16px;
}

.month {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 10px 10px 6px;
  background: var(--paper-raised);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.ed-list {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
}

.ed {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
}

.ed:hover {
  background: var(--accent-soft);
}

.ed[aria-current="true"] {
  background: var(--paper);
  border-color: var(--rule);
  box-shadow: inset 3px 0 0 var(--accent);
}

.ed-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1px;
}

.ed-day b {
  font: 600 1.45rem/1 var(--font);
  font-variant-numeric: lining-nums tabular-nums;
}

.ed-day small {
  margin-top: 3px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.ed-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ed-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.ed-top .no {
  font-weight: 650;
  color: var(--accent);
}

.badge {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ed-lede {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  font: 0.88rem/1.4 var(--font);
  color: var(--ink);
}

.ed-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.tg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 650;
  color: var(--c);
}

.tg::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
}

.tg span {
  display: none;
}

.tg.on {
  padding: 1px 7px 1px 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
}

.tg.on span {
  display: inline;
}

.list-empty {
  margin: 16px 10px;
  color: var(--ink-muted);
  font-style: italic;
}

.side-foot {
  padding: 10px 20px 14px;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: 0.72rem;
}

/* ---------- main pane ---------- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--bar-h);
  padding: 0 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.bar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 600 1rem/1.2 var(--font);
}

.bar-title .no {
  margin-left: 6px;
  font: 650 0.75rem var(--font-ui);
  color: var(--accent);
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bar-mark {
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--rule);
}

.icon-btn,
.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.icon-btn {
  width: 34px;
  padding: 0;
}

.text-btn {
  padding: 0 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

.icon-btn:hover,
.text-btn:hover {
  background: var(--accent-soft);
  border-color: var(--rule);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
  background: none;
  border-color: transparent;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--paper-sunk);
}

.frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--paper);
}

.loading {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--paper-raised);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  color: var(--ink-muted);
  transform: translateX(-50%);
  pointer-events: none;
}

.loading span {
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: absolute;
  bottom: 18px;
  left: 50%;
  z-index: 3;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.82rem;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--paper);
  color: var(--ink-muted);
  font: 1rem/1.5 var(--font);
  text-align: center;
}

.scrim {
  display: none;
}

/* ---------- mobile: sidebar becomes a drawer ---------- */

@media (max-width: 900px) {
  .shell,
  .shell.collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(88vw, var(--side-w));
    box-shadow: var(--shadow);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s 0.2s;
  }

  .shell.open .side {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease;
  }

  .shell.open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgba(20, 16, 20, 0.35);
  }

  .main {
    grid-column: 1;
  }
}

@media (max-width: 560px) {
  .bar {
    flex-wrap: wrap;
    gap: 0 4px;
    height: auto;
    padding: 4px 6px;
  }

  #copy-link {
    display: none;
  }

  .bar-mark {
    order: -1;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 0.6rem;
    text-align: center;
  }

  .bar-title .no {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .side,
  .shell.open .side {
    transition: none;
  }

  .loading span {
    animation: none;
  }
}
