:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f8fafb;
  --panel-strong: #f1f5f6;
  --text: #162126;
  --muted: #66747c;
  --line: #d9e1e5;
  --line-strong: #c2cdd3;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --accent-soft: #dff7f4;
  --amber: #b7791f;
  --amber-soft: #fff3d8;
  --red: #c2413a;
  --red-soft: #ffe4e2;
  --green: #15803d;
  --green-soft: #dcfce7;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 22px 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.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-size: 17px;
  line-height: 1.15;
}

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

.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: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
  transition: 120ms ease;
}

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

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

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

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

.button.danger:hover {
  background: #b42318;
  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.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;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  z-index: 30;
  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(22, 33, 38, 0.08);
  border-radius: 6px;
  background: #162126;
  color: #fff;
  padding: 7px 9px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 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 #162126;
  border-left: 5px solid transparent;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::before,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 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 #162126;
  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%);
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.overview-link:hover,
.overview-link.active {
  background: transparent;
  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-size: 11px;
  font-weight: 800;
}

.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;
  justify-content: space-between;
  gap: 10px;
  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;
}

.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: #fff;
  padding: 10px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 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,
.nav-item.active {
  border-left-color: var(--accent);
  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: #fff;
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

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

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

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

.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;
  gap: 10px;
}

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

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

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

.overview-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.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-size: 24px;
  line-height: 1.2;
}

.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);
  padding: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.overview-stats strong {
  color: var(--text);
  font-size: 19px;
  line-height: 1;
}

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

.overview-card {
  display: block;
  min-width: 0;
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0;
  text-align: left;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.overview-card:hover,
.overview-card.active {
  border-color: var(--accent);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.overview-card.low {
  border-top: 3px solid var(--green);
}

.overview-card.medium {
  border-top: 3px solid var(--amber);
}

.overview-card.high {
  border-top: 3px solid var(--red);
}

.overview-card-main {
  display: grid;
  gap: 12px;
  height: 100%;
  padding: 15px;
}

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

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

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

.card-title-row h4 {
  margin: 0;
  min-width: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.25;
}

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

.category-pill,
.risk,
.mini-tag,
.variable-count,
.updated-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.category-pill {
  max-width: 58%;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 7px 9px;
  color: var(--text);
  text-overflow: ellipsis;
}

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

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

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

.risk {
  padding: 7px 9px;
  background: var(--green-soft);
  color: var(--green);
}

.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-size: 10px;
}

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

.card-metrics span {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

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

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

.mini-tag {
  border: 1px solid var(--line);
  background: #fff;
  padding: 6px 8px;
  color: var(--text);
}

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

.variable-count {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 12px;
}

select,
input,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  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;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.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;
  padding: 24px;
}

.editor-toolbar {
  display: grid;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.editor-head {
  align-items: flex-start;
}

.editor-head > div:first-child {
  flex: 1;
  min-width: 0;
}

.editor-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 2px;
}

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;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
}

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

.editor-status {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.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 {
  color: var(--accent-strong);
}

.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;
}

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

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

.prompt-body-panel {
  display: grid;
  gap: 9px;
}

.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: #fff;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 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: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  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: #fff;
  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 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 {
  padding-left: 20px;
}

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

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

.prompt-preview pre code {
  border: 0;
  background: transparent;
  color: #e5edf5;
  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: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.34);
  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 var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  color: var(--text);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
}

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

.app-notice.warn {
  border-color: var(--amber-soft);
  background: #fffaf0;
}

.app-notice.success {
  border-color: var(--accent-soft);
  background: #f4fbf8;
}

.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: #fff;
  padding: 18px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
}

.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;
}

.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: #fff7f6;
}

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

.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(4, 1fr);
  gap: 8px;
}

.preview-grid.compact strong {
  font-size: 16px;
}

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

.preview-grid strong {
  color: var(--text);
  font-size: 20px;
  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;
}

.placeholder-panel h3 {
  font-size: 15px;
}

code {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  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: #fff;
  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);
}

.score-ring {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  margin: 0;
  border: 10px solid var(--accent-soft);
  border-radius: 50%;
}

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

.score-ring.high {
  border-color: 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: #fffaf0;
}

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

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

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

.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: #704b12;
}

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

.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;
}

.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 {
  min-height: calc(100vh - 80px);
  padding: 24px;
}

.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);
}

@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) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 42vh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

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

  .editor-tabs {
    width: 100%;
  }

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

  .search {
    min-width: 0;
  }

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

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

  .overview-list {
    grid-template-columns: 1fr;
  }

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

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

  .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;
  }

}
