:root {
  color-scheme: light;
  --ink: #17221f;
  --muted: #68736f;
  --line: #dfe5e1;
  --paper: #f4f6f3;
  --panel: #ffffff;
  --shelf: #152720;
  --shelf-muted: #9cb0a8;
  --accent: #e8663f;
  --accent-soft: #fff0ea;
  --green: #397c61;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
}

button, input { font: inherit; }

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

.shelf {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  color: white;
  background: var(--shelf);
  overflow: hidden;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px 16px; border-bottom: 1px solid #304239; }
.brand > div { min-width: 0; flex: 1; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #183026; background: #dce8be; border-radius: 9px; font-family: ui-monospace, monospace; font-size: 12px; font-weight: 800; }
.brand h1, .brand p, .shelf h2, .topbar h2 { margin: 0; }
.brand h1 { font-size: 14px; letter-spacing: -.02em; }
.brand p { margin-top: 3px; color: var(--shelf-muted); font-size: 12px; }
.collapse-button { display: grid; flex: 0 0 auto; place-items: center; width: 24px; height: 24px; padding: 0; color: #bdd0c7; border: 1px solid #3a5146; border-radius: 6px; background: #20352c; cursor: pointer; font-size: 18px; line-height: 1; }
.collapse-button:hover { color: white; border-color: #688477; }
.shelf-resizer { position: absolute; z-index: 5; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; touch-action: none; }
.shelf-resizer::after { position: absolute; top: 0; right: 3px; width: 1px; height: 100%; background: transparent; content: ""; }
.shelf-resizer:hover::after, .resizing-shelf .shelf-resizer::after { background: #83aa97; }
.resizing-shelf { cursor: col-resize; user-select: none; }
.shelf-collapsed { --shelf-width: 52px !important; }
.shelf-collapsed .shelf { padding: 12px 8px; }
.shelf-collapsed .brand { display: grid; justify-items: center; gap: 8px; padding: 0; border-bottom: 0; }
.shelf-collapsed .brand > div,
.shelf-collapsed .source-nav,
.shelf-collapsed .shelf-heading,
.shelf-collapsed .selection-tools,
.shelf-collapsed .search-box,
.shelf-collapsed .file-list,
.shelf-collapsed .shelf-footer,
.shelf-collapsed .shelf-resizer { display: none; }
.shelf-collapsed .collapse-button { transform: none; }
.source-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-top: 10px; padding: 3px; border-radius: 8px; background: #0f211a; }
.source-button { padding: 6px 5px; color: var(--shelf-muted); border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 10px; }
.source-button.active { color: white; background: #294238; box-shadow: 0 1px 3px rgba(0,0,0,.2); }

.shelf-heading, .topbar, .table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.shelf-heading { margin: 16px 4px 9px; }
.shelf-heading h2 { margin-top: 2px; font-size: 17px; }
.eyebrow { color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.shelf .eyebrow { color: #9bc7ad; }
.text-button { padding: 4px; border: 0; color: #dce8e1; background: none; cursor: pointer; font-size: 12px; }
.text-button:hover { color: white; }
.text-button:disabled { opacity: .5; cursor: wait; }
.shelf-actions { display: flex; align-items: center; gap: 5px; }
.add-button { color: #bfe0cd; }
.selection-tools { display: flex; justify-content: flex-end; margin: -5px 2px 4px; }
.selection-tools .text-button { font-size: 10px; }

.search-box { display: flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid #3a4b44; border-radius: 8px; color: var(--shelf-muted); background: #20332b; font-size: 12px; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: inherit; background: transparent; }
.search-box input::placeholder { color: inherit; opacity: .78; }

.file-list { flex: 1; margin-top: 8px; overflow-y: auto; scrollbar-color: #4b5c55 transparent; }
.tree-root, .tree-directory { min-width: 0; }
.tree-root + .tree-root { margin-top: 5px; }
.tree-root summary, .tree-directory summary { display: flex; align-items: center; gap: 6px; min-width: 0; list-style: none; cursor: pointer; user-select: none; }
.tree-root summary::-webkit-details-marker, .tree-directory summary::-webkit-details-marker { display: none; }
.tree-root > summary { padding: 7px 6px; color: #eef5f1; border-radius: 7px; }
.tree-root > summary:hover, .tree-directory > summary:hover { background: #20352c; }
.tree-directory { margin-left: 10px; border-left: 1px solid #354940; }
.tree-directory > summary { padding: 5px 6px; color: #c7d5cf; font-size: 11px; }
.tree-directory > .file-option, .tree-directory > .tree-directory { margin-left: 9px; }
.tree-label { min-width: 0; flex: 1; }
.directory-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-label strong, .tree-label small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-label strong { font-size: 11px; }
.tree-label small { margin-top: 1px; color: var(--shelf-muted); font-size: 9px; font-weight: 400; }
.folder-icon { flex: 0 0 auto; width: 11px; height: 8px; border: 1px solid #779087; border-radius: 2px; background: #2c483c; }
.folder-icon::before { display: block; width: 5px; height: 2px; margin: -3px 0 0 1px; border: 1px solid #779087; border-bottom: 0; border-radius: 2px 2px 0 0; content: ""; }
.root-icon { border-color: #a6cdb5; background: #496d5d; }
.file-option { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 7px; align-items: start; padding: 8px 7px; border-radius: 7px; cursor: pointer; }
.file-option:hover { background: #20352c; }
.file-option:has(input:checked) { background: #294238; }
.file-option input { width: 14px; height: 14px; margin: 1px 0 0; accent-color: #e87955; }
.file-name { display: block; font-size: 11px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; white-space: normal; }
.file-copy { min-width: 0; }
.file-actions { position: sticky; top: 0; right: 3px; display: flex; align-items: center; gap: 3px; padding: 1px 0 1px 4px; background: inherit; }
.convert-icon { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; color: #cce7d8; border: 1px solid #4a6a5b; border-radius: 5px; background: #284238; cursor: pointer; font-size: 12px; line-height: 1; }
.convert-icon:hover { color: white; border-color: #7ca38f; background: #365849; }
.delete-icon, .tree-delete { display: grid; flex: 0 0 auto; place-items: center; width: 20px; height: 20px; padding: 0; color: #caaea5; border: 1px solid transparent; border-radius: 5px; background: transparent; cursor: pointer; font-size: 12px; line-height: 1; }
.delete-icon:hover, .tree-delete:hover { color: #ffd7cc; border-color: #825748; background: #51352c; }
.tree-delete { margin-left: auto; opacity: 0; }
summary:hover > .tree-delete, summary:focus-within > .tree-delete { opacity: 1; }
.source-remove { font-size: 16px; }
.file-size { display: block; margin-top: 2px; color: var(--shelf-muted); font-size: 10px; }
.format-badge { display: inline-flex; flex: 0 0 auto; align-items: center; padding: 2px 5px; color: #66746e; border: 1px solid #ccd5d1; border-radius: 4px; background: #f2f5f3; font-family: ui-monospace, monospace; font-size: 8px; font-weight: 800; letter-spacing: .04em; }
.file-list .format-badge { color: #b9c8c1; border-color: #465c52; background: #243c32; }
.format-badge.atif-badge, .file-list .atif-badge { color: #8e522b; border-color: #efc19f; background: #fff0e5; }
.file-list .atif-badge { color: #ffd1ad; border-color: #825538; background: #513923; }
.format-badge.ml2-badge, .file-list .ml2-badge { color: #35624e; border-color: #b9d4c7; background: #e8f2ed; }
.file-list .ml2-badge { color: #bde3d0; border-color: #47725e; background: #29493b; }
.shelf-footer { padding-top: 10px; color: var(--shelf-muted); border-top: 1px solid #304239; font-size: 10px; }
.shelf-footer code { color: #c9d7d0; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #71b58c; box-shadow: 0 0 0 3px #31503f; }

.workspace { min-width: 0; padding: 22px 28px 32px; }
.topbar { margin-bottom: 14px; }
.topbar h2 { margin-top: 2px; font-family: Georgia, serif; font-size: clamp(24px, 3vw, 32px); font-weight: 500; letter-spacing: -.035em; }
.selection-label { max-width: 45%; padding: 5px 9px; overflow: hidden; color: var(--muted); border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.65); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.metric { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); box-shadow: 0 4px 14px rgba(32,51,43,.035); }
.metric span { display: block; color: var(--muted); font-size: 10px; }
.metric strong { display: block; margin-top: 0; font-family: Georgia, serif; font-size: 20px; font-weight: 500; }
.metric-primary { color: white; border-color: #2e7157; background: var(--green); }
.metric-primary span { color: #d7e9df; }
.language-summary { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.language-summary-title { flex: 0 0 auto; }
.language-summary-title > span { display: block; }
.language-summary-title > span:last-child { margin-top: 2px; color: var(--muted); font-size: 9px; }
.language-stats { display: flex; flex-wrap: wrap; gap: 5px; }
.language-stat { display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px; color: #315f4b; border: 1px solid #c4d8ce; border-radius: 12px; background: #edf5f1; font-size: 9px; }
.language-stat strong { font-size: 9px; }
.language-stat.unknown-stat { color: #746e69; border-color: #d8d4d0; background: #f2f0ee; }

.table-toolbar { margin: 0 0 7px; }
.instance-search { width: min(320px, 100%); border-color: var(--line); color: var(--muted); background: white; }
.instance-search:focus-within { border-color: #8cad9f; box-shadow: 0 0 0 3px #dfeae5; }
.result-count { color: var(--muted); font-size: 10px; }
.content-panel { min-height: 240px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); box-shadow: 0 6px 20px rgba(25,42,35,.04); }
.empty-state { display: grid; place-items: center; align-content: center; min-height: 260px; padding: 24px; text-align: center; }
.empty-glyph { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 11px; color: var(--accent); border: 1px solid #f1cabc; border-radius: 11px; background: var(--accent-soft); font-family: ui-monospace, monospace; font-size: 12px; font-weight: 800; }
.empty-state h3 { margin: 0 0 5px; font-family: Georgia, serif; font-size: 17px; font-weight: 500; }
.empty-state p { max-width: 430px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.instance-table { width: 100%; border-collapse: collapse; }
.instance-table th { padding: 8px 12px; color: var(--muted); background: #f8faf8; border-bottom: 1px solid var(--line); font-size: 9px; letter-spacing: .1em; text-align: left; text-transform: uppercase; }
.instance-table th:last-child, .instance-table td:last-child { width: 100px; text-align: right; }
.instance-table td { padding: 9px 12px; border-bottom: 1px solid #edf0ee; }
.instance-table tr:last-child td { border-bottom: 0; }
.instance-table tbody tr:hover { background: #fbfcfb; }
.instance-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 650; overflow-wrap: anywhere; }
.instance-id.unknown { color: #9a6d5e; font-style: italic; }
.instance-main { display: flex; align-items: center; gap: 7px; min-width: 0; }
.instance-main .instance-id { min-width: 0; }
.language-badge { display: inline-flex; flex: 0 0 auto; padding: 2px 6px; color: #315f4b; border: 1px solid #bfd4ca; border-radius: 10px; background: #eaf3ee; font-family: ui-monospace, monospace; font-size: 8px; font-weight: 750; }
.language-badge.unknown-language { color: #7c7772; border-color: #d8d4d0; background: #f1efed; font-weight: 600; }
.file-breakdown { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.45; overflow-wrap: anywhere; }
.count-badge { display: inline-flex; min-width: 34px; justify-content: center; padding: 3px 7px; color: #a54326; border-radius: 14px; background: var(--accent-soft); font-size: 11px; font-weight: 750; }
.neutral-badge { color: #49635a; background: #eaf0ed; }
.loading { min-height: 260px; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.error { color: #9f3f2a; }
.unknown-section { margin-top: 18px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 0 2px 7px; }
.section-heading h3 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 17px; font-weight: 500; }
.compact-panel { min-height: 0; }

.mind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.control-card { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.control-card > label { display: block; margin-bottom: 6px; font-size: 10px; font-weight: 750; }
.control-card p { margin: 6px 0 0; color: var(--muted); font-size: 9px; }
.inline-control { display: flex; gap: 6px; }
.inline-control input { min-width: 0; flex: 1; padding: 7px 8px; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; outline: 0; font-size: 11px; }
.inline-control input:focus { border-color: #8cad9f; box-shadow: 0 0 0 2px #dfeae5; }
.primary-button, .secondary-button, .row-button { padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 10px; font-weight: 700; }
.primary-button { color: white; border: 1px solid var(--green); background: var(--green); }
.secondary-button, .row-button { color: var(--green); border: 1px solid #a9c2b6; background: #f7faf8; }
.primary-button:disabled, .secondary-button:disabled, .row-button:disabled { opacity: .45; cursor: not-allowed; }
.mind-status { min-height: 22px; padding: 4px 2px; color: var(--muted); font-size: 10px; }
.mind-status.error { color: #a4412b; }
.mind-status.success { color: #28704f; }
.mind-status.working { color: #7b6432; }
.catalog-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.sort-control { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.sort-control select { padding: 6px 8px; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; background: white; font-size: 10px; }
.result-table th:first-child, .result-table td:first-child { width: 70px; }
.result-table th:nth-child(3), .result-table td:nth-child(3) { width: 100px; }
.result-table th:last-child, .result-table td:last-child { width: 100px; }
.status-badge { display: inline-flex; padding: 3px 6px; border-radius: 12px; font-size: 9px; font-weight: 750; text-transform: lowercase; }
.status-badge.done { color: #236246; background: #e2f2e9; }
.status-badge.pending { color: #7b6535; background: #f6efd9; }

.conversion-dialog { width: min(720px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 24px 80px rgba(12,29,22,.28); }
.conversion-dialog::backdrop { background: rgba(11,24,19,.58); backdrop-filter: blur(2px); }
.conversion-dialog form { padding: 18px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.dialog-header h2 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.dialog-header p { max-width: 580px; margin: 3px 0 0; overflow: hidden; color: var(--muted); font-family: ui-monospace, monospace; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { display: grid; place-items: center; width: 25px; height: 25px; padding: 0; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; background: white; cursor: pointer; font-size: 16px; }
.probe-strip { margin: 12px 0; padding: 8px 10px; color: #365d4c; border: 1px solid #c7dbd1; border-radius: 7px; background: #edf5f1; font-size: 10px; }
.probe-strip.error { color: #9f3f2a; border-color: #edc5ba; background: #fff0ec; }
.wizard-section { padding: 11px 0; border-top: 1px solid var(--line); }
.wizard-section h3 { margin: 0 0 7px; font-size: 11px; }
.wizard-section p { margin: 2px 0 0; color: var(--muted); font-size: 9px; }
.form-grid { display: grid; gap: 8px; }
.form-grid.two-columns { grid-template-columns: 1fr 1fr; }
.form-grid.three-columns { grid-template-columns: repeat(3, 1fr); }
.form-grid label { color: var(--muted); font-size: 9px; }
.form-grid input, .form-grid select, .unique-info-row input { display: block; width: 100%; margin-top: 4px; padding: 7px 8px; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; background: white; outline: 0; font-size: 10px; }
.form-grid input:focus, .form-grid select:focus, .unique-info-row input:focus { border-color: #8cad9f; box-shadow: 0 0 0 2px #dfeae5; }
.wizard-title-row { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.unique-info-fields { display: grid; gap: 5px; margin-top: 8px; }
.unique-info-row { display: grid; grid-template-columns: minmax(120px, .7fr) 1.3fr 25px; gap: 6px; }
.unique-info-row input { margin-top: 0; }
.option-row { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 10px; }
.option-row label { display: flex; align-items: center; gap: 5px; }
.option-row input { accent-color: var(--green); }
.dialog-footer { display: flex; justify-content: flex-end; gap: 7px; padding-top: 10px; border-top: 1px solid var(--line); }

@media (max-width: 780px) {
  .app-shell { display: block; }
  .shelf { position: static; width: 100%; height: auto; max-height: 48vh; }
  .file-list { min-height: 100px; }
  .workspace { padding: 20px 14px 28px; }
  .topbar { align-items: flex-end; }
  .selection-label { max-width: 50%; }
  .summary-grid { grid-template-columns: 1fr; }
  .language-summary { align-items: flex-start; flex-direction: column; }
  .mind-grid { grid-template-columns: 1fr; }
  .form-grid.three-columns { grid-template-columns: 1fr; }
  .catalog-toolbar { align-items: stretch; flex-direction: column; }
  .instance-table th, .instance-table td { padding: 8px 9px; }
}
