:root {
  --bg: #f4efe6;
  --bg-side: #efe4d2;
  --bg-prop: #fbf7f1;
  --card: #fffdf8;
  --ink: #1e1a16;
  --muted: #4f473e;
  --line: #e0d3c2;
  --line-strong: #cbbba6;
  --clay: #9a4524;
  --clay-dark: #7a3418;
  --focus: #0f4c81;
  --ok: #145233;
  --ok-bg: #e3f2e8;
  --danger: #6e2418;
  --danger-bg: #f8e6e0;
  --sans: "DejaVu Sans", "Liberation Sans", sans-serif;
  --serif: "DejaVu Serif", "Liberation Serif", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { background: var(--bg); scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

body.modal-open { overflow: hidden; }

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

button { cursor: pointer; }

:focus { outline: none; }

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

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 20;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
}

.skip:focus { top: 12px; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  box-shadow: inset 0 4px 0 var(--ink);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--ink);
  color: #f4ecdf;
  border-radius: 11px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.search {
  flex: 1 1 100%;
  min-width: 0;
}

.search label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.875rem;
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-row input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.action-block {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

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

.actions .btn { flex: 1 1 148px; }

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

input[type="text"],
select {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  min-height: 44px;
  padding: 8px 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 700;
  text-decoration: none;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--ink);
  color: #f6f1e7;
  border-color: var(--ink);
}

.btn-primary:hover { background: #000; }

.btn-move {
  background: transparent;
  color: #6f675d;
  border-color: var(--line-strong);
}

.btn-move:not(:disabled) {
  background: var(--clay);
  border-color: var(--clay);
  color: #fffaf6;
}

.btn-move:not(:disabled):hover { background: var(--clay-dark); }

.btn:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
  font-weight: 700;
}

.btn-ghost:hover { background: rgba(30, 26, 22, 0.05); }

.btn-upload { position: relative; }

.btn-upload input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn-upload:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.ico { width: 18px; height: 18px; flex: 0 0 auto; }

.banner {
  margin: 0;
  padding: 12px 16px;
  overflow-wrap: anywhere;
}

.banner p { margin: 0; }

.banner-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-bottom: 1px solid #e4b5aa;
  box-shadow: inset 4px 0 0 var(--clay);
}

.banner-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-bottom: 1px solid #b7d8c4;
  box-shadow: inset 4px 0 0 #1f7a45;
}

.body { display: flex; flex-direction: column; flex: 1; }

.sidebar {
  background: var(--bg-side);
  border-bottom: 1px solid var(--line);
  padding: 14px 14px 16px;
}

.props h2,
.main h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar h2.side-label {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--muted);
}

.folder-list {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin: 0;
  padding: 0 12px 4px 0;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-color: var(--line-strong) transparent;
}

.folder-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: auto;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  text-align: left;
  white-space: nowrap;
  touch-action: manipulation;
  scroll-snap-align: start;
}

.folder-btn[aria-current="page"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #f6f1e7;
  font-weight: 700;
}

.folder-btn:hover:not([aria-current="page"]) {
  background: #fff;
  border-color: #b7a892;
}

.folder-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.count {
  min-width: 1.4rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  opacity: 0.8;
}

.persist-note {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.main {
  min-width: 0;
  padding: 16px 16px 32px;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.875rem;
}

.crumb-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--clay);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.crumb-current { color: var(--ink); font-weight: 700; }

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

.lede {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.intro {
  margin: 14px 0 0;
  max-width: 62ch;
}

.list-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 4px 16px;
  margin-top: 14px;
}

.check-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 700;
  cursor: pointer;
}

.sel-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.file-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.file + .file { border-top: 1px solid var(--line); }

.file.is-fresh { background: #f8e7dc; }

.file:has(input:checked) {
  background: #f8ece3;
  box-shadow: inset 3px 0 0 var(--clay);
}

.file-hit {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.file:focus-within .file-name {
  display: block;
  -webkit-line-clamp: unset;
}

input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0;
  accent-color: var(--clay);
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  padding: 4px 6px;
  border-radius: 6px;
  background: #efe8dc;
  color: var(--ink);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-PDF { background: #f3ddd4; color: #7a341c; }
.badge-TXT { background: #e8e4dc; color: #3c3833; }
.badge-PNG { background: #dceae4; color: #1d4a3a; }
.badge-JPG { background: #f3ead4; color: #6a4a16; }
.badge-XLSX { background: #dce7df; color: #1c4a34; }

.file-body { min-width: 0; }

.file-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.file-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.h-count {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 400;
}

.empty {
  margin-top: 14px;
  padding: 22px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.7);
  text-align: center;
}

.empty-art {
  width: 140px;
  height: 84px;
  margin: 0 auto 8px;
  color: var(--clay);
}

.empty-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
}

.empty-text {
  margin: 6px auto 0;
  max-width: 42ch;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.props {
  min-width: 0;
  background: var(--bg-prop);
  border-top: 1px solid var(--line);
  padding: 16px 16px 28px;
}

.props-lead {
  margin: 8px 0 0;
  color: var(--muted);
}

.picked {
  margin: 12px 0 0;
  padding-left: 18px;
}

.picked li { overflow-wrap: anywhere; margin: 4px 0; }

.kv { margin: 14px 0 0; }

.kv div {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.kv dt {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
  user-select: text;
}

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

.text-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--clay);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 26, 22, 0.48);
}

.dialog {
  position: relative;
  width: min(460px, 100%);
  max-height: min(640px, calc(100vh - 32px));
  overflow: auto;
  padding: 18px 18px 16px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 24px 70px rgba(36, 22, 12, 0.28);
}

.dialog h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.45rem;
}

.dialog-text {
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.field { display: block; margin-top: 14px; }

.field span {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.field select { width: 100%; }

.move-files {
  margin: 12px 0 0;
  padding-left: 18px;
  max-height: 160px;
  overflow: auto;
}

.move-files li { margin: 4px 0; overflow-wrap: anywhere; }

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.dialog-actions .btn { flex: 1 1 140px; }

@media (max-width: 480px) {
  .dialog-actions { flex-direction: column; }
  .dialog-actions .btn { flex: 1 1 auto; width: 100%; }
}

.dialog-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.fatal { padding: 24px 16px; }

@media (min-width: 960px) {
  .header { padding: 16px 22px 14px; }
  .header-row { flex-wrap: nowrap; align-items: flex-end; }
  .search { flex: 1 1 auto; max-width: 560px; }
  .action-block { flex: 0 0 auto; }
  .body {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 300px;
    align-items: stretch;
  }
  .sidebar {
    display: flex;
    flex-direction: column;
    border-bottom: 0;
    border-right: 1px solid var(--line);
    padding: 18px 14px 20px;
  }
  .folder-list {
    flex-direction: column;
    overflow: visible;
    gap: 4px;
    padding: 0;
  }
  .folder-btn {
    width: 100%;
    border-radius: 10px;
    border-color: transparent;
    background: transparent;
    white-space: normal;
  }
  .folder-btn[aria-current="page"] { border-color: var(--ink); }
  .persist-note { margin-top: auto; }
  .main { padding: 20px 22px 48px; }
  .props {
    border-top: 0;
    border-left: 1px solid var(--line);
    padding: 20px 18px 32px;
  }
  .header { position: sticky; top: 0; z-index: 8; }
}

@media (min-width: 1200px) {
  .body { grid-template-columns: 270px minmax(0, 1fr) 330px; }
}

@media (max-width: 959px) {
  .kbd-hint { display: none; }

  .props.is-active {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7;
    max-height: 42vh;
    overflow: auto;
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 28px rgba(30, 26, 22, 0.12);
    padding-bottom: 14px;
  }

  .props.is-active .kv div { padding: 7px 0; }

  .shell:has(.props.is-active) { padding-bottom: min(42vh, 340px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
