/* Palette inspired by www.une.ru: mint-green page, navy text, steel-blue
 * secondary, deep-green accent; dark theme uses green-tinted near-black. */
:root {
  --bg: #CBF7DE;        /* mint page background */
  --surface: #FFFFFF;   /* white card / table surface */
  --fg: #1D3557;        /* dark navy text */
  --muted: #457B9D;     /* steel-blue secondary */
  --border: #9DDFB8;    /* muted mint border */
  --accent: #2F7A56;    /* deep green — primary */
  --accent-fg: #FFFFFF; /* text on accent */
  --accent-soft: #E0F5E8;
  --row-hover: #EAF8EF;
  --code-bg: #F1F8F4;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(29, 53, 87, 0.08), 0 1px 3px rgba(29, 53, 87, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1F16;
    --surface: #162A1F;
    --fg: #D6F5E0;
    --muted: #7EB89B;
    --border: #2A4A36;
    --accent: #6EE7B7;
    --accent-fg: #0D1F16;
    --accent-soft: #1E3A2A;
    --row-hover: #1B3425;
    --code-bg: #1B3425;
    --danger: #FCA5A5;
    --danger-bg: #3A1717;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="light"] {
  --bg: #CBF7DE; --surface: #FFFFFF; --fg: #1D3557; --muted: #457B9D;
  --border: #9DDFB8; --accent: #2F7A56; --accent-fg: #FFFFFF;
  --accent-soft: #E0F5E8; --row-hover: #EAF8EF; --code-bg: #F1F8F4;
  --danger: #B91C1C; --danger-bg: #FEE2E2;
  --shadow: 0 4px 20px rgba(29, 53, 87, 0.08), 0 1px 3px rgba(29, 53, 87, 0.05);
}
:root[data-theme="dark"] {
  --bg: #0D1F16; --surface: #162A1F; --fg: #D6F5E0; --muted: #7EB89B;
  --border: #2A4A36; --accent: #6EE7B7; --accent-fg: #0D1F16;
  --accent-soft: #1E3A2A; --row-hover: #1B3425; --code-bg: #1B3425;
  --danger: #FCA5A5; --danger-bg: #3A1717;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.site-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  padding-bottom: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.brand h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.search {
  display: block;
  width: min(32rem, 60vw);
}
#search {
  width: 100%;
  padding: 0.55rem 0.85rem;
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#theme-toggle {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 2.25rem; height: 2.25rem;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
#theme-toggle:hover { background: var(--accent-soft); }

.status {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  min-height: 1.25rem;
}
.status.loading::after {
  content: "";
  display: inline-block;
  width: 0.75em; height: 0.75em;
  margin-left: 0.5em;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
thead th {
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--row-hover);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:hover { background: var(--row-hover); }

.col-size, .col-date { width: 7.5rem; }
.col-actions { width: 9rem; }
td.size, td.date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
td.name { min-width: 12rem; }
td.name .title {
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}
td.name a.title { color: var(--accent); }
td.name .title:hover { text-decoration: underline; }
td.name .filename {
  display: block;
  margin-top: 0.2rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}
td.desc { color: var(--fg); }
td.desc .empty-desc { color: var(--muted); font-style: italic; }

.actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--fg);
  background: var(--surface);
  transition: all 120ms;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn.primary:hover {
  filter: brightness(1.08);
  background: var(--accent);
  color: var(--accent-fg);
}
.btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}
.btn .ico { font-size: 0.95em; line-height: 1; }

.empty, .error-panel {
  margin-top: 1rem;
  padding: 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}
.error-panel {
  border-style: solid;
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  text-align: left;
}
.error-panel code { background: transparent; }

footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
footer .muted { opacity: 0.8; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Narrow screens: stack table into cards */
@media (max-width: 720px) {
  .site-header { align-items: stretch; }
  .search { width: 100%; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr {
    border-top: 1px solid var(--border);
    padding: 0.75rem 0;
  }
  tbody td {
    border-top: none;
    padding: 0.25rem 1rem;
  }
  td.size::before { content: "Size: "; color: var(--muted); }
  td.date::before { content: "Updated: "; color: var(--muted); }
  .col-size, .col-date, .col-actions { width: auto; }
}
