/* ./styles-fonts.css */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}

/* ./styles.css */
:root {
  color-scheme: light;
  /* TaskHarbor / ARK palette */
  --bg: #f5f3ed;
  --bg-glow: rgba(199, 155, 66, 0.05);
  --panel: #fffef9;
  --panel-solid: #fffef9;
  --panel-strong: #f5f3ed;
  --panel-muted: #f5f3ed;
  --text: #15201d;
  --muted: #65716c;
  --line: #ebeee7;
  --line-strong: #dfe3dd;
  --accent: #2c6c5a;
  --accent-strong: #102a24;
  --ink: #102a24;
  --accent-soft: #e7f0eb;
  --accent-highlight: #c79b42;
  --amber: #9a650e;
  --amber-soft: #f8efdc;
  --red: #b33a32;
  --red-soft: #f8e6e3;
  --green: #247a52;
  --green-soft: #e7f0eb;
  --shadow: 0 22px 80px rgba(21, 32, 29, 0.18);
  --shadow-soft: 0 16px 48px rgba(21, 32, 29, 0.08);
  --radius: 8px;
  --radius-pill: 999px;
  --font: "Noto Sans KR", Geist, Pretendard, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Noto Sans KR", Geist, Pretendard, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Dark theme: tokens only; the sidebar is already dark in both themes */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1714;
  --bg-glow: rgba(199, 155, 66, 0.04);
  --panel: #16221e;
  --panel-solid: #16221e;
  --panel-strong: #1b2a25;
  --panel-muted: #1b2a25;
  --text: #e9efea;
  --muted: #93a49d;
  --line: #23342e;
  --line-strong: #2e453c;
  --accent: #5fb08f;
  --accent-strong: #e9efea;
  --ink: #2a4a3f;
  --accent-soft: #1c3329;
  --amber: #e0a84a;
  --amber-soft: #3a2d14;
  --red: #e5736b;
  --red-soft: #3d2220;
  --green: #4fae82;
  --green-soft: #17302a;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 16px 48px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse at top left, var(--bg-glow), transparent 42%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
  font-weight: 400;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, #102a24 0%, #102a24 58%, #102a24 100%);
  color: #f5f3ed;
  padding: 20px 16px;
}

.sidebar-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-navigation {
  display: contents;
}

.button.nav-toggle {
  display: none;
  white-space: nowrap;
}

.brand,
.brand-home {
  display: flex;
  align-items: center;
  gap: 12px;
}

button.brand-home {
  border: 0;
  background: transparent;
  padding: 6px;
  margin: -6px;
  border-radius: var(--radius);
  text-align: left;
  color: inherit;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

button.brand-home:hover,
button.brand-home:focus-visible {
  background: #17362e;
  box-shadow: none;
  outline: none;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 6px;
  border: 1px solid rgba(199, 155, 66, 0.35);
  border-radius: var(--radius);
  background: #15201d;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel-head h3,
.placeholder-panel h3,
.placeholder-panel p,
.empty-state h3,
.empty-state p {
  margin: 0;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand p,
.topbar p,
.placeholder-panel p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.brand p {
  color: #91a39c;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  min-height: 38px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.button:hover,
.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.button.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.danger {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.button.danger:hover {
  background: #b33a32;
  color: #fff;
}

.button.ghost {
  background: var(--panel);
}

.button.ghost.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.audit-toggle strong {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 22px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
}

.audit-toggle.medium strong {
  background: var(--amber-soft);
  color: var(--amber);
}

.audit-toggle.high strong {
  background: var(--red-soft);
  color: var(--red);
}

.button.compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.button.subtle {
  border-color: var(--line);
  background: var(--panel-muted);
  color: var(--muted);
}

.button.subtle:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.button.full {
  width: 100%;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
}

.icon-button.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

[data-icon] svg {
  display: block;
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

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

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
}

.sidebar :focus-visible {
  outline-color: var(--accent-highlight);
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  z-index: 30;
  display: none;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity 120ms ease 300ms, transform 120ms ease 300ms;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  left: 50%;
  top: calc(100% + 8px);
  width: max-content;
  max-width: 230px;
  border: 1px solid rgba(21, 32, 29, 0.08);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  padding: 7px 9px;
  box-shadow: 0 10px 24px rgba(21, 32, 29, 0.16);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
}

[data-tooltip]::after {
  content: "";
  left: 50%;
  top: calc(100% + 4px);
  border-right: 5px solid transparent;
  border-bottom: 5px solid var(--ink);
  border-left: 5px solid transparent;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::before,
[data-tooltip]:focus-visible::after {
  display: block;
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Keep tooltips on right-edge controls inside the viewport */
.editor-actions [data-tooltip]::before,
.body-view-tabs [data-tooltip]::before,
.topbar-actions [data-tooltip]::before,
#restoreButton[data-tooltip]::before {
  left: auto;
  right: 0;
  transform: translate(0, 4px);
}

.editor-actions [data-tooltip]:hover::before,
.body-view-tabs [data-tooltip]:hover::before,
.topbar-actions [data-tooltip]:hover::before,
#restoreButton[data-tooltip]:hover::before,
.editor-actions [data-tooltip]:focus-visible::before,
.body-view-tabs [data-tooltip]:focus-visible::before {
  transform: translate(0, 0);
}

[data-tooltip][data-tooltip-position="right"]::before,
[data-tooltip][data-tooltip-position="right"]::after {
  left: calc(100% + 10px);
  top: 50%;
  transform: translate(4px, -50%);
}

[data-tooltip][data-tooltip-position="right"]::after {
  left: calc(100% + 5px);
  border-top: 5px solid transparent;
  border-right: 5px solid var(--ink);
  border-bottom: 5px solid transparent;
  border-left: 0;
}

[data-tooltip][data-tooltip-position="right"]:hover::before,
[data-tooltip][data-tooltip-position="right"]:hover::after,
[data-tooltip][data-tooltip-position="right"]:focus-visible::before,
[data-tooltip][data-tooltip-position="right"]:focus-visible::after {
  transform: translate(0, -50%);
}

select,
input,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  outline: 0;
}

select {
  height: 40px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  padding: 10px 11px;
  font-weight: 500;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(44, 108, 90, 0.14);
}

.empty-state h3,
.topbar h2,
.panel-head h3 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.02em;
}

@keyframes notice-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .overview-card:hover,
  .overview-card.active,
  .button.primary:hover {
    transform: none;
  }
}

/* ./styles-layout.css */
.nav-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.overview-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 10px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.overview-link:hover,
.overview-link.active {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(44, 108, 90, 0.14);
  color: var(--accent-strong);
}

.overview-link strong {
  display: inline;
  min-width: 0;
  height: auto;
  margin-left: auto;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.overview-link.active strong {
  background: transparent;
  color: var(--accent-strong);
}

.section-head,
.panel-head,
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-list,
.prompt-list,
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-list {
  gap: 8px;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-node {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 9px 8px 9px 10px;
  color: var(--text);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
}

.nav-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-head .icon-button {
  border-color: transparent;
  background: transparent;
}

.section-head .icon-button:hover {
  border-color: transparent;
  background: transparent;
  color: var(--accent-strong);
}

.category-form {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  padding: 10px;
  box-shadow: 0 8px 18px rgba(21, 32, 29, 0.05);
}

.category-form[hidden] {
  display: none;
}

.category-form input {
  min-height: 36px;
}

.category-form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.nav-item:hover {
  border-left-color: var(--accent);
  background: transparent;
  color: var(--accent-strong);
}

.nav-item.active {
  border-left-color: var(--accent-highlight);
  background: transparent;
  color: var(--accent-strong);
}

.nav-item span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.category-children {
  display: grid;
  gap: 4px;
  margin-left: 31px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.category-prompt {
  display: block;
  width: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 4px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-prompt:hover,
.category-prompt.active {
  background: transparent;
  color: var(--text);
}

.tag-cloud,
.placeholder-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.placeholder-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-solid);
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
}

.tag.active,
.placeholder-chip {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tag-toggle {
  border-style: dashed;
  background: var(--panel-muted);
  color: var(--accent-strong);
}

.storage {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.storage-card {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.storage-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.storage-row.primary {
  color: var(--text);
  font-weight: 800;
}

.storage-row span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.main {
  min-width: 0;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 18px 24px;
}

.topbar h2 {
  font-size: 22px;
  line-height: 1.2;
}

.app-status {
  margin-bottom: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  min-width: 0;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 320px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  padding: 0 12px;
  color: var(--muted);
}

.export-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
  padding: 4px;
}

.export-group .button {
  min-height: 32px;
  border-color: transparent;
  background: transparent;
}

.search input {
  width: 100%;
  height: 38px;
  border: 0;
  outline: 0;
  box-shadow: none;
}

.search input:focus {
  border: 0;
  box-shadow: none;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(44, 108, 90, 0.14);
}

.search input::-webkit-search-cancel-button {
  cursor: pointer;
  filter: grayscale(1) opacity(0.6);
}

.overview-list > .empty-state {
  grid-column: 1 / -1;
  min-height: 180px;
}

.workspace {
  min-height: calc(100vh - 79px);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 9px;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state [data-icon] svg {
  width: 34px;
  height: 34px;
}

.empty-state h3 {
  color: var(--text);
  font-size: 16px;
}

.editor-empty-state {
  align-content: center;
  gap: 12px;
  min-height: calc(100vh - 80px);
  padding: 24px;
}

.editor-empty-state h3,
.editor-empty-state p {
  margin: 0;
}

.empty-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.text-action {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 0;
  font-size: 13px;
  font-weight: 800;
}

.text-action:hover,
.text-action.primary {
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.text-action.danger {
  color: var(--red);
}

.text-action.danger:hover {
  border-bottom-color: var(--red);
}

/* Sidebar dark chrome (matches the design-system sibling app: dark navy sidebar, lime accent) */

.sidebar .button.nav-toggle {
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #dfe8e3;
}

.sidebar .button.nav-toggle:hover {
  border-color: var(--accent);
  color: #ffffff;
}

.sidebar .button.primary {
  border-color: var(--accent-highlight);
  background: var(--accent-highlight);
  color: var(--accent-strong);
}

.sidebar .button.primary:hover {
  border-color: #b58a35;
  background: #b58a35;
  color: var(--accent-strong);
}

.overview-link {
  color: #91a39c;
}

.overview-link:hover,
.overview-link.active {
  background: #17362e;
  border-color: transparent;
  color: #ffffff;
}

.overview-link strong {
  color: #91a39c;
}

.overview-link.active strong {
  color: #ffffff;
}

.section-head h2 {
  color: #91a39c;
}

.sidebar .section-head .icon-button {
  color: #91a39c;
}

.sidebar .section-head .icon-button:hover {
  color: #ffffff;
}

.nav-item {
  color: #dfe8e3;
}

.nav-item:hover {
  background: #17362e;
  color: #ffffff;
}

.nav-item.active {
  background: #17362e;
  color: #ffffff;
}

.nav-item span:last-child {
  color: #7f938b;
}

.category-children {
  border-left-color: rgba(255, 255, 255, 0.1);
}

.category-prompt {
  color: #91a39c;
}

.category-prompt:hover,
.category-prompt.active {
  color: #ffffff;
}

.category-form {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 32px rgba(2, 6, 12, 0.35);
}

.tag,
.tag-toggle {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #dfe8e3;
}

.tag.active {
  border-color: var(--accent-highlight);
  background: rgba(199, 155, 66, 0.16);
  color: var(--accent-highlight);
}

.tag-toggle {
  color: #91a39c;
}

.tag-toggle:hover {
  color: #ffffff;
}

.storage {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.storage-card {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

.storage-row {
  color: #91a39c;
}

.storage-row.primary {
  color: #f5f3ed;
}

.sidebar .button.ghost {
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #dfe8e3;
}

.sidebar .button.ghost:hover {
  border-color: var(--accent);
  color: #ffffff;
}

.sidebar-version {
  padding-top: 4px;
  color: #7f938b;
  font-size: 11px;
  font-weight: 700;
}

.nav-symbol {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-highlight);
}

.nav-symbol [data-icon] svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.2;
}

.nav-item:hover .nav-symbol,
.nav-item.active .nav-symbol {
  border-color: rgba(216, 243, 106, 0.3);
  background: rgba(199, 155, 66, 0.16);
}

.overview-link .nav-symbol {
  width: 20px;
  height: 20px;
}

/* Category form: sit on the dark sidebar instead of a white card */
.category-form {
  background: var(--sidebar-raised, #17362e);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.category-form input {
  min-height: 34px;
  border-color: rgba(255, 255, 255, 0.14);
  background: #102a24;
  color: #f5f3ed;
  font-size: 13px;
}

.category-form input::placeholder {
  color: #7f938b;
}

.category-form input:focus {
  border-color: var(--accent-highlight);
  box-shadow: 0 0 0 3px rgba(199, 155, 66, 0.2);
}

.category-form .button.ghost {
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #dfe8e3;
}

.category-form .button.ghost:hover {
  border-color: #dfe8e3;
  color: #ffffff;
}

.search-hint {
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel-strong);
  padding: 1px 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
}

.search:focus-within .search-hint {
  display: none;
}

@media (hover: none), (max-width: 840px) {
  .search-hint {
    display: none;
  }
}

.nav-row {
  position: relative;
}

.nav-edit {
  position: absolute;
  top: 50%;
  right: 34px;
  transform: translateY(-50%);
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #91a39c;
  opacity: 0;
  cursor: pointer;
  transition: opacity 120ms ease, color 120ms ease, background-color 120ms ease;
}

.nav-edit svg {
  width: 14px;
  height: 14px;
}

.nav-row:hover .nav-edit,
.nav-row:focus-within .nav-edit,
.nav-edit:focus-visible {
  opacity: 1;
}

.nav-edit:hover {
  background: #17362e;
  color: #ffffff;
}

@media (hover: none) {
  .nav-edit {
    opacity: 0.7;
  }
}

.tag-clear {
  border-color: var(--accent-highlight);
  background: transparent;
  color: var(--accent-highlight);
}

.tag-clear:hover {
  background: rgba(199, 155, 66, 0.16);
}

.button.icon-only {
  width: 38px;
  padding: 0;
}

.button.icon-only svg {
  width: 17px;
  height: 17px;
}

.storage-usage {
  display: grid;
  gap: 4px;
  padding: 0 2px 2px;
}

.storage-usage-bar {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.storage-usage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #4fae82;
  transition: width 200ms ease, background-color 200ms ease;
}

.storage-usage[data-level="warn"] .storage-usage-bar span {
  background: var(--accent-highlight);
}

.storage-usage[data-level="high"] .storage-usage-bar span {
  background: #e5736b;
}

.storage-usage small {
  color: #91a39c;
  font-size: 11px;
}

.trash-list {
  display: grid;
  gap: 10px;
}

.trash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  padding: 14px 16px;
}

.trash-item-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.trash-item-main strong {
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-item-main span {
  color: var(--muted);
  font-size: 12px;
}

.trash-item-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.button.danger-outline {
  border-color: var(--red);
  background: transparent;
  color: var(--red);
}

.button.danger-outline.armed,
.button.danger-outline:hover {
  background: var(--red);
  color: #fff;
}

@media (max-width: 560px) {
  .trash-item {
    flex-direction: column;
    align-items: stretch;
  }

  .trash-item-actions .button {
    flex: 1 1 0;
  }
}

.tag-manager-list {
  display: grid;
  gap: 8px;
}

.tag-manager-row {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  padding: 10px 14px;
}

.tag-manager-row.editing input {
  flex: 1 1 auto;
  min-width: 0;
}

.tag-manager-count {
  color: var(--muted);
  font-size: 12px;
}

.tag-manager-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

mark {
  border-radius: 2px;
  background: rgba(199, 155, 66, 0.38);
  padding: 0 1px;
  color: inherit;
}

@media (max-width: 560px) {
  .tag-manager-row {
    flex-wrap: wrap;
  }

  .tag-manager-actions {
    width: 100%;
    margin-left: 0;
  }

  .tag-manager-actions .button {
    flex: 1 1 0;
  }
}

.rules-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.rules-dirty {
  color: var(--amber);
  font-size: 12px;
  font-weight: 600;
}

.rules-tester {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 12px 14px;
}

.rules-tester textarea {
  resize: vertical;
}

.rules-test-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rules-test-hint {
  color: var(--muted);
  font-size: 12px;
}

.rules-list {
  display: grid;
  gap: 12px;
}

.rule-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  padding: 14px 16px;
}

.rule-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rule-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 12px;
}

.rule-wide {
  grid-column: 1 / -1;
}

.rule-grid input.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.rule-error {
  min-height: 0;
  margin: 0;
  color: var(--red);
  font-size: 12px;
}

.rule-error:empty {
  display: none;
}

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

  .rule-grid label:first-child {
    grid-column: 1 / -1;
  }
}

/* ./styles-overview.css */
.overview-panel {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 24px;
  box-shadow: var(--shadow-soft);
}

.overview-panel[hidden] {
  display: none;
}

.overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.overview-head h3,
.overview-head p {
  margin: 0;
}

.overview-head h3 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.overview-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 8px;
  min-width: 420px;
}

.overview-stats span {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.overview-stats strong {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
}

.overview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: -4px;
}

.overview-toolbar-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.sort-tabs {
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  padding: 2px;
}

.sort-tabs button {
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.sort-tabs button:hover {
  color: var(--accent-strong);
}

.sort-tabs button.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

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

.overview-card-wrap {
  position: relative;
  min-width: 0;
}

.overview-card-wrap > .overview-card {
  width: 100%;
  height: 100%;
}

.card-pin,
.card-copy {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel-solid);
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 120ms ease, color 120ms ease, border-color 120ms ease;
}

.card-pin {
  right: 46px;
}

.card-pin svg,
.card-copy svg {
  width: 14px;
  height: 14px;
}

.card-pin.active {
  border-color: var(--accent-highlight);
  color: var(--accent-highlight);
  opacity: 1;
}

.card-pin.active svg {
  fill: currentColor;
}

.overview-card-wrap:hover .card-copy,
.overview-card-wrap:focus-within .card-copy,
.overview-card-wrap:hover .card-pin,
.overview-card-wrap:focus-within .card-pin,
.card-copy:focus-visible,
.card-pin:focus-visible {
  opacity: 1;
}

.card-copy:hover,
.card-pin:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.card-pin.active:hover {
  border-color: var(--accent-highlight);
  color: var(--accent-highlight);
}

@media (hover: none) {
  .card-copy,
  .card-pin {
    opacity: 1;
  }
}

.overview-card {
  display: block;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  padding: 0;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.overview-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.overview-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.overview-card-main {
  display: grid;
  align-content: start;
  gap: 10px;
  height: 100%;
  padding: 14px 16px;
}

.card-topline,
.card-title-row,
.card-footer,
.card-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-topline {
  justify-content: space-between;
}

.card-title-row {
  align-items: baseline;
  justify-content: space-between;
}

.card-title-row h4 {
  margin: 0;
  min-width: 0;
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.overview-card p {
  display: -webkit-box;
  min-height: 38px;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.category-pill,
.risk,
.mini-tag,
.updated-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.category-pill {
  max-width: 62%;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

.category-dot {
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
}

.category-dot.medium {
  background: var(--amber);
}

.category-dot.high {
  background: var(--red);
}

.risk {
  border-radius: 4px;
  padding: 2px 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}

.overview-card.active .risk.low {
  background: var(--panel-solid);
}

.risk.medium {
  background: var(--amber-soft);
  color: var(--amber);
}

.risk.high {
  background: var(--red-soft);
  color: var(--red);
}

.updated-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Inline stat row separated by hairlines, instead of three boxed cells */
.card-metrics {
  gap: 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.card-metrics span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 0 12px;
  border-left: 1px solid var(--line);
}

.card-metrics span:first-child {
  padding-left: 0;
  border-left: 0;
}

.card-metrics strong {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.overview-card .tag-row {
  padding-right: 68px;
}

.overview-card.pinned {
  border-top: 2px solid var(--accent-highlight);
}

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

.mini-tag {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-strong);
  padding: 2px 6px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

.overview-card.active .mini-tag {
  background: var(--panel-solid);
}

.muted-tag {
  color: var(--muted);
}

.overview-toolbar .add-starter {
  margin-left: auto;
}

/* ./styles-editor.css */
.editor-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.editor-column[hidden] {
  display: none;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 24px;
  box-shadow: var(--shadow-soft);
}

.editor-toolbar {
  display: grid;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-muted);
  margin: -24px -24px 0;
  padding: 18px 24px;
}

.editor-head {
  display: flex;
  align-items: center;
}

.editor-title-block {
  flex: 1;
  min-width: 0;
}

.editor-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.title-input {
  width: 100%;
  padding: 2px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
}

.title-input:focus {
  box-shadow: none;
}

.editor-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.editor-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.editor-status[data-state="saved"]::before {
  background: var(--green);
}

.editor-status[data-state="dirty"],
.editor-status[data-state="draft"] {
  color: var(--amber);
}

.editor-status[data-state="dirty"]::before,
.editor-status[data-state="draft"]::before {
  background: var(--amber);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  padding: 4px;
}

.editor-actions .icon-button {
  border-color: transparent;
  background: transparent;
}

.editor-actions .icon-button:hover {
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent-strong);
}

.editor-actions .save-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.editor-actions .save-action:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.editor-tabs {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(100%, 430px);
  border: 0;
  background: transparent;
  padding: 0;
}

.editor-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 32px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 2px;
  font-size: 13px;
  font-weight: 800;
}

.editor-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  box-shadow: none;
}

.tab-panel {
  display: grid;
  gap: 18px;
}

.tab-panel[hidden] {
  display: none;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  align-items: start;
  gap: 14px;
  padding-top: 2px;
}

.category-custom {
  margin-top: 7px;
}

.stacked textarea {
  resize: vertical;
  line-height: 1.5;
}

.prompt-body-panel {
  display: grid;
  gap: 9px;
  border-top: 1px solid var(--line);
  padding-top: 2px;
}

.prompt-body-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.prompt-body-head label {
  font-size: 13px;
  font-weight: 700;
}

.body-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.body-copy-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.body-copy-button:hover {
  color: var(--text);
}

.body-copy-button svg {
  width: 16px;
  height: 16px;
}

.body-view-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 3px;
}

.body-view-tabs button {
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 900;
}

.body-view-tabs button.active {
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(21, 32, 29, 0.08);
}

.body-view-panel[hidden] {
  display: none;
}

.body-view-panel,
.prompt-body-panel textarea,
.prompt-preview {
  height: 360px;
}

.prompt-body-panel textarea {
  min-height: 360px;
  resize: none;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
}

.prompt-preview {
  min-height: 360px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  padding: 14px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}

.prompt-preview h3,
.prompt-preview h4,
.prompt-preview h5,
.prompt-preview p,
.prompt-preview ul,
.prompt-preview ol,
.prompt-preview pre,
.preview-table-wrap {
  margin: 0 0 12px;
}

.prompt-preview h3 {
  font-size: 18px;
}

.prompt-preview h4 {
  font-size: 16px;
}

.prompt-preview h5 {
  font-size: 14px;
}

.prompt-preview ul,
.prompt-preview ol {
  padding-left: 20px;
}

.prompt-preview code {
  background: var(--panel);
}

.prompt-preview pre {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #102a24;
  padding: 12px;
}

.prompt-preview pre code {
  border: 0;
  background: transparent;
  color: #e8eef4;
  padding: 0;
}

.preview-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.prompt-preview th,
.prompt-preview td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.prompt-preview th {
  background: var(--panel);
  color: var(--text);
  font-weight: 900;
}

.prompt-preview tr:last-child td {
  border-bottom: 0;
}

.preview-empty {
  color: var(--muted);
}

.placeholder-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
  padding: 14px;
}

.placeholder-panel h3 {
  font-size: 15px;
  font-family: var(--font-display);
  font-weight: 500;
}

.placeholder-fill {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.placeholder-fill-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.placeholder-fill-head h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.placeholder-fill-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.fill-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.fill-field-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-strong);
}

.fill-field input {
  min-height: 38px;
}

code {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-solid);
  padding: 1px 4px;
  color: var(--accent-strong);
}

.audit-panel,
.history-panel {
  display: grid;
  gap: 14px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  padding: 15px;
}

.audit-panel {
  grid-template-columns: 148px minmax(0, 1fr);
  align-items: start;
}

.audit-panel .panel-head,
.audit-panel .audit-details,
.audit-panel .audit-findings {
  grid-column: 1 / -1;
}

.panel-head h3 {
  font-size: 16px;
}

.audit-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.audit-actions .icon-button {
  border-color: transparent;
  background: transparent;
}

.audit-actions .icon-button:hover {
  border-color: transparent;
  background: transparent;
  color: var(--accent-strong);
}

/* Progress ring: --score (0-100) is set from the audit result */
.score-ring {
  --ring-color: var(--green);
  --ring-track: var(--green-soft);
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  width: 112px;
  height: 112px;
  margin: 0;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--score, 0) * 1%), var(--ring-track) 0);
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--panel-solid);
}

.score-ring > * {
  position: relative;
}

.score-ring.medium {
  --ring-color: var(--amber);
  --ring-track: var(--amber-soft);
}

.score-ring.high {
  --ring-color: var(--red);
  --ring-track: var(--red-soft);
}

.score-ring strong {
  font-size: 30px;
  line-height: 1;
}

.score-ring span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.audit-breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-self: center;
}

.score-card {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 11px;
}

.score-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-card strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.score-card small {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.score-card.warn {
  border-color: var(--amber-soft);
  background: var(--amber-soft);
}

.score-card.final.low {
  border-color: var(--green-soft);
  background: var(--green-soft);
}

.score-card.final.medium {
  border-color: var(--amber-soft);
  background: var(--amber-soft);
}

.score-card.final.high {
  border-color: var(--red-soft);
  background: var(--red-soft);
}

.audit-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.audit-details section {
  display: grid;
  gap: 9px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
}

.audit-details h4 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.audit-checks,
.suggestion-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit-checks li {
  display: grid;
  gap: 3px;
  border-left: 3px solid var(--green);
  padding-left: 9px;
}

.audit-checks li.review {
  border-color: var(--amber);
}

.audit-checks strong {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.factor-id {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--text);
  font-size: 10px;
  line-height: 18px;
}

.audit-checks span,
.suggestion-list li,
.export-warning {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.export-warning {
  margin: 0;
}

.export-warning.high {
  color: var(--red);
  font-weight: 800;
}

.audit-findings {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit-findings li {
  border-left: 3px solid var(--line-strong);
  padding-left: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.audit-findings li.warn {
  border-color: var(--amber);
  color: var(--amber);
}

.audit-findings li.high {
  border-color: var(--red);
  color: var(--red);
}

.history-diff {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-diff:empty {
  display: none;
}

.history-diff-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.history-diff-head h4 {
  margin: 0;
  font-size: 14px;
}

.history-diff-head span,
.history-diff-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.diff-lines {
  overflow: auto;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
}

.diff-line {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
}

.diff-line code {
  padding: 1px 10px 1px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-mark {
  text-align: center;
  color: var(--muted);
  user-select: none;
}

.diff-line.add {
  background: var(--green-soft);
}

.diff-line.add .diff-mark {
  color: var(--green);
  font-weight: 700;
}

.diff-line.del {
  background: var(--red-soft);
}

.diff-line.del .diff-mark {
  color: var(--red);
  font-weight: 700;
}

.history-item {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px;
  text-align: left;
}

.history-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.history-item strong {
  font-size: 12px;
}

.history-item span {
  color: var(--muted);
  font-size: 11px;
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.preset-bar select {
  min-width: 180px;
  max-width: 100%;
}

.preset-name-form {
  display: flex;
  flex: 1 1 100%;
  gap: 8px;
}

.preset-name-form[hidden],
.preset-bar select[hidden] {
  display: none;
}

.preset-name-form input {
  flex: 1 1 auto;
  min-width: 0;
}

.preset-name-form .button,
.preset-bar .button {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* ./styles-modals.css */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(21, 32, 29, 0.42);
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.app-notice {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 44px));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
  background: #15201d;
  box-shadow: var(--shadow);
  color: #f5f3ed;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  animation: notice-enter 220ms ease;
}

.app-notice[hidden] {
  display: none;
}

.app-notice .notice-action {
  margin-left: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: transparent;
  padding: 4px 10px;
  color: #f5f3ed;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.app-notice .notice-action:hover {
  border-color: var(--accent-highlight);
  color: var(--accent-highlight);
}

.app-notice.warn {
  border-left-color: var(--accent-highlight);
}

.app-notice.success {
  border-left-color: #4fae82;
}

.auth-panel {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #102a24;
}

:root[data-theme="dark"] .auth-panel {
  background: #0e1714;
}

.auth-panel[hidden] {
  display: none;
}

body.auth-active {
  overflow: hidden;
}

body.auth-active .app-shell {
  height: 100vh;
  overflow: hidden;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius);
  background: var(--panel-solid);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.22);
  padding: 26px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-card h2 {
  margin: 2px 0 0;
  font-size: 20px;
}

.auth-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.auth-status {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  width: min(620px, 100%);
  max-height: calc(100vh - 40px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  padding: 18px;
  box-shadow: var(--shadow);
  animation: modal-enter 200ms ease;
}

.modal h2 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modal h2,
.modal p {
  margin: 0;
}

.modal h2 {
  font-size: 20px;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.modal p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.delete-modal,
.unsaved-modal {
  width: min(460px, 100%);
}

.delete-summary,
.unsaved-summary {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-radius: var(--radius);
  padding: 13px;
}

.delete-summary {
  border: 1px solid var(--red-soft);
  background: var(--red-soft);
}

.unsaved-summary {
  border: 1px solid var(--amber-soft);
  background: var(--amber-soft);
}

.delete-summary [data-icon] {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
}

.delete-summary strong,
.unsaved-summary strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 14px;
}

.import-preview-body {
  display: grid;
  gap: 13px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preview-grid span {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.preview-grid strong {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

.import-safety-note {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.preview-list {
  display: grid;
  gap: 8px;
}

.preview-list div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.preview-list span {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1320px) {
  .editor-column {
    grid-template-columns: 1fr;
  }

}

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

  .workspace {
    grid-template-columns: 1fr;
  }

  .overview-head {
    flex-direction: column;
  }

  .overview-stats {
    width: 100%;
    min-width: 0;
  }

}

@media (max-width: 840px) {
  [data-tooltip]::before,
  [data-tooltip]::after,
  [data-tooltip]:hover::before,
  [data-tooltip]:hover::after,
  [data-tooltip]:focus-visible::before,
  [data-tooltip]:focus-visible::after {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 12px;
    max-height: none;
    overflow: visible;
    padding: 14px;
  }

  .sidebar-topline {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #102a24;
    padding-bottom: 10px;
  }

  .button.nav-toggle {
    display: inline-flex;
  }

  .sidebar.mobile-compact:not(.nav-expanded) .sidebar-navigation {
    display: none;
  }

  .sidebar.mobile-compact.nav-expanded .sidebar-navigation {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .topbar,
  .topbar-actions,
  .editor-head,
  .editor-control-row,
  .placeholder-panel,
  .modal-head,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions > *,
  .search,
  .export-group {
    width: 100%;
  }

  .export-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-tabs {
    width: 100%;
    gap: 10px;
    overflow-x: auto;
  }

  .editor-actions {
    justify-content: flex-end;
  }

  .search {
    min-width: 0;
  }

  .overview-panel,
  .editor {
    padding: 18px;
  }

  .editor-toolbar {
    margin: -18px -18px 0;
    padding: 16px 18px;
  }

  .overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-list {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .audit-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-ring {
    justify-self: center;
  }

  .audit-panel {
    grid-template-columns: 1fr;
  }

  .audit-panel .panel-head,
  .audit-panel .audit-details,
  .audit-panel .audit-findings {
    grid-column: auto;
  }

  .audit-details {
    grid-template-columns: 1fr;
  }

  .auth-card,
  .modal {
    width: 100%;
  }

  .prompt-body-head,
  .body-head-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .body-view-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-notice {
    right: 14px;
    bottom: 14px;
    max-width: calc(100vw - 28px);
  }

}

@media (max-width: 560px) {
  .overview-list {
    grid-template-columns: 1fr;
  }
}

/* Compact mobile chrome: keep the header from eating the first screen */
@media (max-width: 840px) {
  .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
  }

  .sidebar > .sidebar-topline,
  .sidebar > .sidebar-navigation,
  .sidebar > .sidebar-version {
    grid-column: 1 / -1;
  }

  .sidebar-topline {
    padding-bottom: 0;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 13px;
  }

  .brand-copy p,
  .sidebar-version {
    display: none;
  }

  .sidebar .button.primary.full {
    width: auto;
    min-height: 40px;
  }

  .overview-link {
    min-height: 40px;
    gap: 10px;
    padding: 0 12px;
  }

  .topbar {
    gap: 10px;
    padding: 14px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: stretch;
    gap: 8px;
  }

  .topbar-actions > .search {
    grid-column: 1 / -1;
    grid-row: 1;
    width: auto;
  }

  #importButton {
    grid-column: 1;
    grid-row: 2;
  }

  #themeToggleButton {
    grid-column: 2;
    grid-row: 2;
  }

  #languageToggleButton {
    grid-column: 3;
    grid-row: 2;
  }

  .export-group {
    grid-column: 1 / -1;
    grid-row: 3;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: auto;
    padding: 2px;
  }

  .topbar-actions .button {
    min-height: 38px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .editor-control-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .editor-tabs {
    width: auto;
    flex: 1 1 auto;
  }

  .prompt-body-head {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  .body-head-actions {
    display: contents;
  }

  .body-copy-button {
    order: 2;
  }

  .body-view-tabs {
    order: 3;
    width: 100%;
  }
}

@media (max-width: 380px) {
  .topbar-actions .button span:not([data-icon]) {
    font-size: 12px;
  }

  .sidebar .button.primary.full {
    padding: 0 10px;
  }
}

