@font-face {
  font-family: "Pangolin";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/pangolin-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "Pangolin";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/pangolin-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Pangolin";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/pangolin-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Pangolin";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/pangolin-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root,
html[data-theme="dark"] {
  --bg: #071018;
  --bg-image:
    radial-gradient(circle at 12% 0%, rgba(92, 160, 190, 0.16), transparent 28%),
    linear-gradient(180deg, #08131c 0%, #071018 42%, #0a1620 100%);
  --sidebar-bg: linear-gradient(180deg, rgba(8, 20, 30, 0.96), rgba(6, 14, 22, 0.92));
  --topbar-bg: rgba(7, 16, 24, 0.78);
  --panel: rgba(8, 18, 28, 0.88);
  --panel-soft: rgba(12, 28, 40, 0.72);
  --line: rgba(214, 186, 112, 0.38);
  --line-soft: rgba(130, 190, 210, 0.18);
  --cyan: #7cecff;
  --gold: #e4c16a;
  --text: #e8f4ff;
  --text-soft: #d5e7ef;
  --muted: #8eaab8;
  --land: #8fb36a;
  --danger: #ff8a7a;
  --btn-text: #d7eef8;
  --btn-border: rgba(160, 220, 255, 0.28);
  --nav-hover: rgba(28, 56, 72, 0.55);
  --input-bg: rgba(5, 12, 18, 0.7);
  --html-row-bg: rgba(20, 48, 38, 0.35);
  --link-box-bg: rgba(48, 28, 72, 0.35);
  --file-row-bg: rgba(42, 36, 20, 0.4);
  --thumb-bg: rgba(16, 36, 28, 0.8);
  --thumb-color: #9be7b2;
  --add-bg: rgba(10, 24, 34, 0.7);
  --intro-overlay: linear-gradient(120deg, rgba(18, 42, 54, 0.72), rgba(10, 22, 32, 0.78));
  --backdrop: rgba(3, 8, 12, 0.72);
  --font-hand: "Pangolin", "Segoe UI", system-ui, sans-serif;
  --font-body: "Segoe UI", system-ui, sans-serif;
}

html[data-theme="light"] {
  --bg: #f4efe4;
  --bg-image:
    radial-gradient(circle at 12% 0%, rgba(180, 210, 230, 0.42), transparent 28%),
    linear-gradient(180deg, #f7f3ea 0%, #efe8d8 42%, #e7f0f4 100%);
  --sidebar-bg: linear-gradient(180deg, rgba(255, 252, 246, 0.97), rgba(236, 242, 246, 0.95));
  --topbar-bg: rgba(255, 250, 240, 0.88);
  --panel: rgba(255, 252, 247, 0.96);
  --panel-soft: rgba(255, 255, 255, 0.82);
  --line: rgba(160, 120, 40, 0.38);
  --line-soft: rgba(70, 110, 130, 0.16);
  --cyan: #0f6f86;
  --gold: #9a6f12;
  --text: #16303c;
  --text-soft: #2a4450;
  --muted: #5d7380;
  --land: #4f7a38;
  --danger: #b42318;
  --btn-text: #16303c;
  --btn-border: rgba(40, 80, 100, 0.22);
  --nav-hover: rgba(210, 230, 238, 0.88);
  --input-bg: rgba(255, 255, 255, 0.9);
  --html-row-bg: rgba(220, 240, 228, 0.72);
  --link-box-bg: rgba(236, 226, 255, 0.72);
  --file-row-bg: rgba(250, 236, 204, 0.72);
  --thumb-bg: rgba(226, 240, 232, 0.95);
  --thumb-color: #1f6b48;
  --add-bg: rgba(255, 252, 246, 0.86);
  --intro-overlay: linear-gradient(120deg, rgba(255, 248, 236, 0.84), rgba(230, 240, 244, 0.8));
  --backdrop: rgba(40, 50, 60, 0.35);
  --font-hand: "Pangolin", "Segoe UI", system-ui, sans-serif;
  --font-body: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-image);
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-hand);
  font-size: 16px;
  line-height: 1.45;
}

body {
  min-height: 100vh;
}

button,
.file-label {
  font: inherit;
}

input,
textarea,
.rm-input,
.rm-comment {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}

.intro p,
.card p,
.chat-message p,
.chat-empty,
.empty,
.dropzone p,
.dropzone small {
  font-family: var(--font-body);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--line-soft);
  background: var(--sidebar-bg);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #06202a;
  background: linear-gradient(180deg, #d8c07a, #b8923b);
  border-radius: 10px;
}

.brand b,
.crumb h1,
.editor h2 {
  display: block;
  letter-spacing: 0.02em;
  font-weight: 400;
}

.brand small,
.eyebrow,
.muted,
.card time,
.save-state,
.nav small {
  color: var(--muted);
}

.archive-play-link {
  display: block;
  position: relative;
  z-index: 3;
  margin-top: 8px;
  color: var(--cyan);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.01em;
  pointer-events: auto;
}

.archive-play-link:hover {
  color: var(--gold);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-group {
  margin-top: 10px;
}

.nav-group > small {
  display: block;
  padding: 8px 10px 4px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 10px;
  cursor: pointer;
}

.nav-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  object-fit: contain;
  border-radius: 8px;
  background: #f4efe6;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

html[data-theme="light"] .nav-icon {
  background: #fffdf8;
  box-shadow: inset 0 0 0 1px rgba(22, 48, 60, 0.12);
}

.intro-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 8px;
}

.intro-heading h2 {
  margin: 0;
}

.section-title-icon {
  width: 112px;
  height: 112px;
  flex: 0 0 112px;
  object-fit: contain;
  border-radius: 18px;
  background: #f4efe6;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

html[data-theme="light"] .section-title-icon {
  background: #fffdf8;
  box-shadow: inset 0 0 0 1px rgba(22, 48, 60, 0.12);
}

.nav-label {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

.count-pill {
  min-width: 1.5em;
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(124, 236, 255, 0.14);
  color: var(--cyan);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.nav button:hover,
.nav button:focus-visible,
.nav button.active {
  border-color: var(--line);
  background: var(--nav-hover);
}

.nav button.active {
  box-shadow: inset 0 0 0 1px rgba(124, 236, 255, 0.18);
}

.nav-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
}

.nav-row > button:first-child {
  width: 100%;
}

.tiny {
  min-width: 32px;
  padding: 6px 8px;
  border-radius: 8px;
}

.add-structure {
  width: 100%;
  margin-top: 16px;
  justify-content: center;
}

.back-link {
  display: inline-block;
  margin-top: 22px;
  color: var(--cyan);
  text-decoration: none;
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 18px 132px 14px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 4;
}

.crumb {
  min-width: 180px;
}

.crumb h1 {
  margin: 2px 0 0;
  font-size: 22px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
}

.search input,
.card,
.intro,
.tabs,
.editor form,
.dropzone {
  border: 1px solid var(--line-soft);
  background: var(--panel-soft);
}

.search input {
  width: min(320px, 42vw);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
}

.stats,
.top-actions,
.card-head,
.card-actions,
.editor footer,
.check-row,
.thumbs {
  display: flex;
  gap: 10px;
  align-items: center;
}

.stats {
  color: var(--muted);
  font-size: 12px;
}

.stats b,
.save-state {
  color: var(--cyan);
}

.top-actions {
  margin-left: auto;
}

.folder-btn.is-on {
  color: var(--cyan);
  border-color: var(--cyan);
}

.theme-toggle {
  position: absolute;
  top: 18px;
  right: 22px;
  min-width: 96px;
  color: var(--gold);
  border-color: var(--line);
  z-index: 5;
}

.main {
  padding: 20px 22px 40px;
}

.intro,
.card,
.editor form {
  border-radius: 16px;
}

.intro {
  padding: 18px 20px;
  margin-bottom: 16px;
  background:
    var(--intro-overlay),
    url("assets/sector-5,4-detailed-8k.jpg") center / cover no-repeat;
}

.intro.intro-factions,
body.section-factions .intro {
  background:
    var(--intro-overlay),
    url("assets/faction-icons-banner.png?v=16") center / cover no-repeat;
}

.intro h2,
.intro p,
.card h3,
.card p {
  margin: 0 0 8px;
}

.intro .intro-heading h2 {
  margin: 0;
}

.intro p,
.card p {
  color: var(--text-soft);
  line-height: 1.5;
  white-space: pre-wrap;
}

.featured {
  width: 100%;
  max-height: 280px;
  margin-top: 10px;
  object-fit: contain;
  object-position: center;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 12px;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.kind-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.kind-switch button {
  border-radius: 999px;
}

.kind-switch button.active,
.primary,
#save-note,
#save-structure,
#chat-send {
  color: #06202a;
  background: linear-gradient(180deg, #d8c07a, #b8923b);
  border-color: transparent;
}

.card-text { border-top: 3px solid #7cecff; }
.card-image { border-top: 3px solid #e4c16a; }
.card-html { border-top: 3px solid #9be7b2; }
.card-link { border-top: 3px solid #c9a0ff; }
.card-file { border-top: 3px solid #f0b27a; }

.badge.kind-text { color: #7cecff; }
.badge.kind-image { color: #e4c16a; }
.badge.kind-html { color: #9be7b2; }
.badge.kind-link { color: #d4b8ff; }
.badge.kind-file { color: #f0b27a; }

.gallery-large {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.html-list,
.file-list,
.link-box {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.html-row,
.file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: var(--html-row-bg);
}

.file-row {
  justify-content: space-between;
  background: var(--file-row-bg);
}

.file-row strong,
.file-thumb span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.link-box {
  padding: 12px;
  border-radius: 12px;
  background: var(--link-box-bg);
}

.resource-link {
  color: #d4b8ff;
  word-break: break-all;
}

.html-thumb,
.file-thumb,
.thumb-btn {
  position: relative;
  min-width: 92px;
  min-height: 64px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--thumb-bg);
  color: var(--thumb-color);
  cursor: pointer;
}

.file-thumb {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 140px;
  color: #f0b27a;
  text-align: left;
}

html[data-theme="light"] .file-thumb {
  color: #8a4b12;
}

.html-preview {
  border: 0;
  width: min(960px, 94vw);
  height: min(80vh, 720px);
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

/* Native <dialog> is display:none until [open]. A bare display:flex
   keeps the empty preview bar in the page flow (bottom of the archive). */
.file-preview {
  flex-direction: column;
}

.file-preview[open] {
  display: flex;
}

.file-preview:not([open]) {
  display: none;
}

.html-preview header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.html-preview iframe,
.file-preview-body {
  width: 100%;
  height: calc(100% - 58px);
  border: 0;
  background: #fff;
  color: #16303c;
}

.file-preview header {
  gap: 12px;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.preview-toolbar {
  padding: 8px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel-soft);
}

.preview-toolbar select {
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 6px 10px;
}

.file-preview-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 18px;
}

.file-preview-body iframe,
.file-preview-body pre,
.file-preview-body img {
  display: block;
  width: 100%;
  min-height: 100%;
  margin: 0;
}

.file-preview-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.5 Consolas, "Courier New", monospace;
}

.preview-doc p {
  margin: 0 0 10px;
  line-height: 1.5;
}

.preview-table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 13px;
}

.preview-table td {
  border: 1px solid #c5d4dc;
  padding: 6px 8px;
  vertical-align: top;
  white-space: pre-wrap;
}

.preview-empty {
  margin: 24px 8px;
  color: #5d7380;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  margin-bottom: 16px;
  border-radius: 14px;
}

.tabs button,
.ghost,
.file-label,
.card-actions button,
.editor button {
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid rgba(160, 220, 255, 0.28);
  background: transparent;
  color: var(--btn-text);
  border-color: var(--btn-border);
  padding: 8px 14px;
}

.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tabs button.active {
  color: #06202a;
  background: linear-gradient(180deg, #d8c07a, #b8923b);
  border-color: transparent;
}

.tabs button.active .count-pill {
  color: #06202a;
  background: rgba(6, 32, 42, 0.12);
}

.chat {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  background: var(--panel-soft);
  border-radius: 16px;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.chat-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.06em;
}

.chat-log {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.chat-empty {
  margin: 0;
  color: var(--muted);
}

.chat-message {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--file-row-bg);
}

.chat-message p {
  margin: 0;
  color: var(--text-soft);
  white-space: pre-wrap;
}

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
  align-items: end;
}

.chat-form textarea {
  width: 100%;
  color: var(--text);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--input-bg);
  padding: 10px 12px;
  resize: vertical;
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  padding: 16px;
  min-height: 180px;
}

.card-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.card h3 {
  font-size: 17px;
}

.card time,
.badge {
  font-size: 12px;
}

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(124, 236, 255, 0.12);
  color: var(--cyan);
}

.badge.done {
  color: #9be7b2;
  background: rgba(80, 180, 110, 0.16);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.gallery img,
.thumbs img,
.lightbox img {
  width: 100%;
  display: block;
  object-fit: cover;
  border-radius: 8px;
}

.gallery button,
.thumbs button {
  padding: 0;
  border: 0;
  background: none;
  position: relative;
}

.card-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.danger {
  color: var(--danger);
  border-color: rgba(255, 138, 122, 0.35);
}

.editor {
  border: 0;
  padding: 0;
  background: transparent;
}

.editor::backdrop,
.lightbox::backdrop {
  background: var(--backdrop);
}

.editor form {
  width: min(720px, 92vw);
  padding: 22px;
  background: var(--panel);
}

.editor label,
.check-row {
  display: block;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.editor input[type="text"],
.editor input:not([type="checkbox"]):not([type="file"]),
.editor textarea {
  width: 100%;
  margin-top: 6px;
  color: var(--text);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--input-bg);
  padding: 10px 12px;
}

.dropzone {
  padding: 18px;
  text-align: center;
  border-style: dashed;
  border-radius: 12px;
}

.dropzone.drag {
  border-color: var(--gold);
  background: rgba(228, 193, 106, 0.08);
}

.thumbs {
  flex-wrap: wrap;
  margin-top: 12px;
}

.thumbs .thumb {
  width: 92px;
  position: relative;
}

.thumbs .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 0;
  padding: 2px 7px;
}

.editor footer {
  justify-content: flex-end;
  margin-top: 16px;
}

.lightbox {
  border: 0;
  padding: 18px;
  background: transparent;
  max-width: 92vw;
}

.lightbox img {
  max-height: 80vh;
  width: auto;
  max-width: 90vw;
}

.empty,
.add-card {
  color: var(--muted);
  text-align: center;
}

.add-card {
  min-height: 180px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-style: dashed;
}

.icon {
  display: none;
  min-width: 42px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.file-label {
  display: inline-flex;
  align-items: center;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(320px, 86vw);
    transform: translateX(-110%);
    z-index: 8;
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: none;
  }

  .icon {
    display: inline-flex;
    justify-content: center;
  }

  .search input {
    width: 100%;
  }

  .top-actions,
  .stats {
    width: 100%;
  }
}

.board.roadmap-board {
  grid-template-columns: 1fr;
  gap: 16px;
}

.rm-styles,
.rm-summary,
.rm-item {
  border: 1px solid var(--line-soft);
  background: var(--panel-soft);
  border-radius: 16px;
}

.rm-styles {
  padding: 16px 18px 18px;
}

.rm-styles-kicker,
.rm-summary small {
  display: block;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.rm-style-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.rm-style-card {
  display: grid;
  gap: 8px;
  text-align: left;
  color: var(--text);
  background: var(--add-bg);
  border: 1px solid var(--btn-border);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
}

.rm-style-card strong {
  letter-spacing: 0.04em;
}

.rm-style-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.rm-style-card.active {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(228, 193, 106, 0.35);
}

.rm-style-preview {
  height: 54px;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  background: rgba(8, 24, 32, 0.45);
}

html[data-theme="light"] .rm-style-preview {
  background: rgba(255, 255, 255, 0.55);
}

.rm-style-timeline .rm-style-preview {
  background:
    linear-gradient(90deg, transparent 18px, var(--gold) 18px, var(--gold) 20px, transparent 20px),
    rgba(8, 24, 32, 0.45);
}

.rm-style-timeline .rm-style-preview i,
.rm-style-cards .rm-style-preview b,
.rm-style-ledger .rm-style-preview em {
  position: absolute;
  display: block;
}

.rm-style-timeline .rm-style-preview i {
  left: 12px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
}

.rm-style-timeline .rm-style-preview i:nth-child(1) { top: 8px; }
.rm-style-timeline .rm-style-preview i:nth-child(2) { top: 22px; width: 10px; height: 10px; left: 14px; }
.rm-style-timeline .rm-style-preview i:nth-child(3) { top: 36px; }

.rm-style-cards .rm-style-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
}

.rm-style-cards .rm-style-preview b {
  position: static;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(124, 236, 255, 0.28), rgba(228, 193, 106, 0.2));
}

.rm-style-ledger .rm-style-preview em {
  left: 10px;
  right: 10px;
  height: 8px;
  border-radius: 999px;
  background: rgba(124, 236, 255, 0.28);
}

.rm-style-ledger .rm-style-preview em:nth-child(1) { top: 12px; }
.rm-style-ledger .rm-style-preview em:nth-child(2) { top: 24px; width: 70%; }
.rm-style-ledger .rm-style-preview em:nth-child(3) { top: 36px; width: 84%; }

.rm-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
}

.rm-summary strong {
  display: block;
  color: var(--gold);
  font-size: 28px;
  letter-spacing: 0.04em;
}

.rm-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(124, 236, 255, 0.12);
  overflow: hidden;
}

.rm-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5aa7c4, #e4c16a);
}

.rm-item[data-tone="low"] .rm-bar i { background: linear-gradient(90deg, #c46a5a, #e4a16a); }
.rm-item[data-tone="mid"] .rm-bar i { background: linear-gradient(90deg, #5aa7c4, #e4c16a); }
.rm-item[data-tone="high"] .rm-bar i { background: linear-gradient(90deg, #5aa77a, #c4d86a); }

.rm-list {
  display: grid;
  gap: 14px;
}

.rm-item {
  padding: 16px;
}

.rm-child {
  background: var(--add-bg);
}

.rm-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.rm-title-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.rm-num {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.rm-child .rm-num {
  color: var(--text);
  font-weight: 700;
  opacity: 0.85;
}

.rm-title,
.rm-input,
.rm-comment {
  width: 100%;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 8px 10px;
}

.rm-title {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.rm-comment {
  resize: vertical;
  min-height: 64px;
}

.rm-meter {
  display: grid;
  grid-template-columns: auto auto 72px 1fr;
  gap: 10px;
  align-items: center;
}

.rm-count {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.rm-ring {
  position: relative;
  width: 52px;
  height: 52px;
}

.rm-ring svg {
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
}

.rm-ring-bg,
.rm-ring-fg {
  fill: none;
  stroke-width: 4;
}

.rm-ring-bg { stroke: rgba(124, 236, 255, 0.16); }
.rm-ring-fg { stroke: var(--gold); stroke-linecap: round; }
.rm-ring[data-tone="low"] .rm-ring-fg { stroke: #e48a6a; }
.rm-ring[data-tone="high"] .rm-ring-fg { stroke: #9be7b2; }

.rm-ring b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
}

.rm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rm-children {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.rm-timeline .rm-item:not(.rm-child) {
  position: relative;
  padding-left: 28px;
  border-left: 2px solid var(--gold);
  border-radius: 0 16px 16px 0;
}

.rm-timeline .rm-item:not(.rm-child)::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 22px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
}

.rm-timeline .rm-children {
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px dashed var(--line);
}

.rm-cards {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.rm-cards .rm-item:not(.rm-child) {
  min-height: 240px;
}

.rm-cards .rm-head {
  justify-items: start;
}

.rm-cards .rm-ring {
  width: 72px;
  height: 72px;
}

.rm-cards .rm-ring svg {
  width: 72px;
  height: 72px;
}

.rm-cards .rm-ring b {
  font-size: 14px;
}

.rm-cards .rm-children {
  grid-template-columns: 1fr;
}

.rm-ledger .rm-item {
  padding: 10px 12px;
  border-radius: 10px;
}

.rm-ledger .rm-head {
  grid-template-columns: minmax(180px, 1.1fr) minmax(240px, 1.2fr) auto;
  align-items: center;
}

.rm-ledger .rm-comment {
  min-height: 42px;
  grid-column: 1 / -1;
}

.rm-ledger .rm-children {
  margin-top: 8px;
}

.rm-ledger .rm-child {
  margin-left: 22px;
}

.rm-ledger .rm-ring {
  display: none;
}

.rm-links {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.rm-links-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.rm-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rm-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  color: var(--text);
  background: var(--add-bg);
  border: 1px solid var(--btn-border);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  text-align: left;
  cursor: pointer;
}

.rm-link:hover,
.rm-link:focus-visible {
  border-color: var(--gold);
}

.rm-link-copy {
  display: grid;
  flex: 1;
  gap: 1px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.rm-link-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.rm-link-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}

.rm-link.missing {
  opacity: 0.72;
}

.rm-link-remove {
  min-width: 0;
  padding: 2px 8px;
  color: var(--danger);
}

.note-picker form {
  width: min(640px, 92vw);
  max-height: min(82vh, 760px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.note-picker-list {
  overflow: auto;
  min-height: 180px;
  max-height: 48vh;
  display: grid;
  gap: 14px;
  padding: 4px 2px 8px;
}

.note-picker-group {
  display: grid;
  gap: 6px;
}

.note-picker-items {
  display: grid;
  gap: 6px;
}

.note-picker-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.note-picker .note-picker-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  color: var(--text);
  background: var(--add-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.note-picker .note-picker-item:hover,
.note-picker .note-picker-item:focus-visible {
  border-color: var(--gold);
}

.note-picker .note-picker-item.attached {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(228, 193, 106, 0.28);
}

.note-picker .note-picker-item small {
  color: var(--muted);
  font-size: 12px;
}

.note-picker-empty {
  color: var(--muted);
  font-family: var(--font-body);
  padding: 18px 8px;
}

.card.note-focus {
  outline: 2px solid var(--gold);
  box-shadow: 0 0 0 6px rgba(228, 193, 106, 0.22);
  animation: note-focus-pulse 1.6s ease;
}

@keyframes note-focus-pulse {
  0% { box-shadow: 0 0 0 0 rgba(228, 193, 106, 0.42); }
  100% { box-shadow: 0 0 0 10px rgba(228, 193, 106, 0); }
}

@media (max-width: 980px) {
  .rm-style-grid,
  .rm-cards,
  .rm-ledger .rm-head,
  .rm-meter,
  .rm-summary {
    grid-template-columns: 1fr;
  }
}
