﻿:root {
      color-scheme: light;
      --bg: #f7f6f2;
      --surface: #fffdfa;
      --panel: #ffffff;
      --input: #ffffff;
      --table-head: #f8f7f3;
      --table-line: #ebe8df;
      --status: #f3f1eb;
      --ink: #202124;
      --label: #353638;
      --table-label: #4b4c4d;
      --muted: #65676b;
      --line: #d9d6cd;
      --accent: #306366;
      --accent-2: #b6422c;
      --soft: #edf4f4;
      --shadow: 0 10px 28px rgba(35, 31, 25, 0.08);
    }

    body[data-theme="dark"] {
      color-scheme: dark;
      --bg: #101516;
      --surface: #151d1f;
      --panel: #1b2426;
      --input: #111819;
      --table-head: #202b2d;
      --table-line: #2d3a3d;
      --status: #202b2d;
      --ink: #edf4f4;
      --label: #d7e2e3;
      --table-label: #c1d0d2;
      --muted: #9eb0b3;
      --line: #344346;
      --accent: #7fb0b4;
      --accent-2: #e08a73;
      --soft: #243436;
      --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      min-height: 100vh;
      background: var(--bg);
      color: var(--ink);
      font-family: Arial, Helvetica, sans-serif;
      letter-spacing: 0;
    }

    header {
      padding: 18px clamp(16px, 4vw, 48px) 10px;
      background: var(--surface);
    }

    .header-inner {
      position: relative;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      padding: 50px;
      box-shadow: var(--shadow);
    }

    .theme-toggle {
      position: absolute;
      top: 16px;
      right: 16px;
      min-height: 34px;
      padding: 6px 12px;
      border: 1px solid var(--line);
      border-radius: 6px;
      color: var(--accent);
      background: var(--soft);
      font-weight: 700;
    }

    h1 {
      margin: 0 0 50px;
      text-align: center;
      font-size: clamp(28px, 4vw, 44px);
      line-height: 1.05;
    }

    .sub {
      margin: 0 auto;
      color: var(--muted);
      max-width: 860px;
      text-align: center;
      line-height: 1.45;
    }


    .app-tabs {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      max-width: 520px;
      margin: 20px auto 0;
    }

    .tab-button {
      min-height: 42px;
      border: 1px solid var(--line);
      border-radius: 6px;
      color: var(--accent);
      background: var(--soft);
      font-weight: 700;
      cursor: pointer;
    }

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

    .view-hidden {
      display: none !important;
    }

    .guide {
      margin-top: 14px;
      display: grid;
      grid-template-columns: repeat(4, minmax(130px, 1fr));
      gap: 8px;
    }

    .step {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--bg);
      padding: 10px 12px;
      font-size: 13px;
      line-height: 1.35;
    }

    .step strong {
      display: block;
      color: var(--accent);
      margin-bottom: 4px;
      font-size: 18px;
    }

    .expander-controls {
      padding: 18px;
      align-self: start;
    }

    .expander-controls h3 {
      margin: 0 0 14px;
      font-size: 18px;
    }

    .expander-results {
      min-width: 0;
      overflow: hidden;
    }

    .expander-table-wrap {
      max-height: 420px;
    }

    .expander-summary {
      grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    main {
      display: grid;
      grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
      gap: 18px;
      padding: 18px clamp(16px, 4vw, 48px) 32px;
    }

    .site-footer {
      padding: 0 clamp(16px, 4vw, 48px) 28px;
      color: var(--muted);
      font-size: 13px;
      text-align: center;
    }

    .panel {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: var(--shadow);
    }

    .controls {
      padding: 18px;
      align-self: start;
      position: sticky;
      top: 12px;
    }

    .results {
      min-width: 0;
      overflow: hidden;
    }

    h2 {
      margin: 0 0 14px;
      font-size: 18px;
    }

    .control-group {
      position: relative;
      margin: 0 0 14px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--surface);
    }

    .control-group legend {
      padding: 0 7px;
      color: var(--accent);
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
    }

    .control-group label:first-of-type {
      margin-top: 2px;
    }

    .field-help {
      display: none;
      position: absolute;
      left: 12px;
      right: 12px;
      top: calc(100% - 3px);
      z-index: 10;
      margin: 0;
      padding: 8px 10px;
      border: 1px solid var(--line);
      border-radius: 6px;
      color: var(--ink);
      background: var(--panel);
      box-shadow: var(--shadow);
      font-size: 12px;
      line-height: 1.35;
      pointer-events: none;
    }

    .control-group:focus-within > .field-help,
    .control-group:has(> label:hover) > .field-help,
    .control-group:has(> input:hover) > .field-help,
    .control-group:has(> textarea:hover) > .field-help,
    .control-group:has(> select:hover) > .field-help,
    .control-group:has(.stars:hover) > .field-help,
    .control-group:has(.key-grid:hover) > .field-help,
    .row > div:focus-within > .field-help,
    .row > div:has(> label:hover) > .field-help,
    .row > div:has(> input:hover) > .field-help,
    .row > div:has(> select:hover) > .field-help,
    .row > div:has(> textarea:hover) > .field-help {
      display: block;
    }

    label {
      display: block;
      margin: 10px 0 6px;
      font-size: 13px;
      font-weight: 700;
      color: var(--label);
    }

    input, select, textarea, button {
      font: inherit;
      letter-spacing: 0;
    }

    input[type="file"],
    input[type="number"],
    input[type="text"],
    textarea,
    select {
      width: 100%;
      min-height: 40px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: var(--input);
      color: var(--ink);
      padding: 9px 10px;
    }

    input[type="file"] {
      min-height: 54px;
      border: 2px solid var(--accent);
      background: var(--soft);
      cursor: pointer;
      font-weight: 700;
      padding: 14px 12px;
      line-height: 1.2;
    }

    .control-group.database-group {
      padding-top: 14px;
      padding-bottom: 14px;
    }

    .database-group label {
      margin: 4px 0 10px;
    }

    .preset-group select {
      margin-top: 0;
    }

    .preset-actions {
      display: grid;
      grid-template-columns: 1fr 1fr 74px;
      gap: 8px;
      margin-top: 10px;
    }

    .preset-actions button {
      min-height: 36px;
      padding: 7px 9px;
      font-size: 12px;
    }

    .preset-state {
      margin-top: 9px;
      min-height: 30px;
      padding: 7px 9px;
      border: 1px solid var(--line);
      border-radius: 6px;
      color: var(--muted);
      background: var(--status);
      font-size: 12px;
      line-height: 1.25;
    }

    .preset-help {
      margin: 8px 0 0;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.35;
    }

    textarea {
      min-height: 72px;
      resize: vertical;
      line-height: 1.35;
    }

    .row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-top: 8px;
    }

    .row > div {
      position: relative;
    }

    .inline-control {
      position: relative;
      display: grid;
      grid-template-columns: minmax(0, 1fr) 110px;
      align-items: center;
      gap: 12px;
      margin-top: 10px;
    }

    .inline-control label {
      margin: 0;
    }

    .inline-control input {
      min-height: 38px;
      padding: 7px 9px;
    }

    .inline-control:focus-within .field-help,
    .inline-control:has(label:hover) .field-help,
    .inline-control:has(input:hover) .field-help {
      display: block;
    }

    .stars {
      display: grid;
      grid-template-columns: repeat(5, minmax(0, 1fr));
      gap: 6px;
    }

    .stars label {
      display: block;
      margin: 0;
      min-width: 0;
    }

    .stars input { display: none; }

    .stars span {
      display: grid;
      place-items: center;
      min-height: 36px;
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: var(--input);
      cursor: pointer;
      font-weight: 700;
    }

    .stars input:checked + span {
      border-color: var(--accent);
      background: var(--soft);
      color: var(--accent);
    }

    .key-grid {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 6px;
    }

    .key-grid label {
      display: block;
      margin: 0;
      min-width: 0;
    }

    .key-grid input { display: none; }

    .key-grid span {
      display: grid;
      place-items: center;
      min-height: 34px;
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: var(--input);
      cursor: pointer;
      font-size: 12px;
      font-weight: 700;
    }

    .key-grid input:checked + span {
      border-color: var(--accent);
      background: var(--soft);
      color: var(--accent);
    }

    .actions {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
      margin: 18px 10px 0;
    }

    .actions button {
      width: 100%;
    }

    .result-actions {
      display: grid;
      justify-content: end;
      padding: 14px 16px 16px;
      border-top: 1px solid var(--line);
    }

    .result-actions button {
      min-width: 150px;
      min-height: 42px;
      padding: 10px 18px;
    }

    .controls > .status,
    .controls .expander-only > .status {
      margin-left: 10px;
      margin-right: 10px;
    }

    button {
      min-height: 42px;
      border: 0;
      border-radius: 6px;
      color: #fff;
      background: var(--accent);
      font-weight: 700;
      cursor: pointer;
    }

    button.secondary {
      color: var(--accent);
      background: var(--soft);
      border: 1px solid #b8cfd1;
    }

    button.full {
      width: 100%;
      margin-top: 10px;
    }

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

    .status {
      margin-top: 14px;
      min-height: 42px;
      padding: 10px 12px;
      border-radius: 6px;
      background: var(--status);
      color: var(--muted);
      line-height: 1.35;
      font-size: 13px;
    }

    .summary {
      display: grid;
      grid-template-columns: repeat(4, minmax(120px, 1fr));
      border-bottom: 1px solid var(--line);
      background: var(--surface);
    }

    .metric {
      padding: 14px 16px;
      border-right: 1px solid var(--line);
    }

    .metric:last-child { border-right: 0; }

    .metric strong {
      display: block;
      font-size: 22px;
      line-height: 1.1;
    }

    .metric span {
      display: block;
      margin-top: 3px;
      color: var(--muted);
      font-size: 12px;
    }

    .active-filters {
      padding: 9px 16px;
      border-bottom: 1px solid var(--line);
      color: var(--muted);
      background: var(--status);
      font-size: 12px;
      line-height: 1.35;
    }

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

    .toolbar input {
      max-width: 360px;
      min-height: 36px;
    }

    .table-wrap {
      overflow: auto;
      max-height: calc(100vh - 235px);
    }

    table {
      width: 100%;
      border-collapse: collapse;
      min-width: 920px;
      font-size: 13px;
    }

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

    th {
      position: sticky;
      top: 0;
      z-index: 1;
      background: var(--table-head);
      font-size: 12px;
      color: var(--table-label);
    }

    .path {
      color: var(--muted);
      font-size: 12px;
      max-width: 360px;
      word-break: break-word;
    }

    .tag {
      display: inline-block;
      margin: 0 4px 4px 0;
      padding: 2px 6px;
      border-radius: 999px;
      background: #edf4f4;
      color: #28575a;
      white-space: nowrap;
    }

    .tag-select {
      margin-top: 8px;
      background: var(--surface);
      border-color: #b8cfd1;
    }

    .row-actions {
      display: flex;
      flex-wrap: nowrap;
      align-items: center;
      gap: 5px;
      margin-top: 5px;
      white-space: nowrap;
    }

    .mini-button {
      display: inline-flex;
      flex: 0 0 auto;
      align-items: center;
      justify-content: center;
      min-height: 24px;
      margin-top: 0;
      padding: 3px 7px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: var(--status);
      font-size: 11px;
      font-weight: 700;
      cursor: pointer;
    }

    .exclude-button {
      color: var(--accent-2);
      border-color: #e1c1b8;
    }

    .swap-button {
      color: var(--accent);
      border-color: #b8cfd1;
    }

    .tag-empty {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.35;
    }

    .warn { color: var(--accent-2); }

    @media (max-width: 980px) {
      main { grid-template-columns: 1fr; }
      .controls { position: static; }
      .guide { grid-template-columns: 1fr 1fr; }
      .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .table-wrap { max-height: none; }
    }

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