:root {
  color-scheme: light dark;
  --bg: #edf2f7;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --surface-blue: #eef5ff;
  --text: #111827;
  --muted: #64748b;
  --subtle: #94a3b8;
  --line: #d9e2ee;
  --line-strong: #c4cfdd;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 18px 42px rgba(15, 23, 42, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  min-height: 100%;
  background: linear-gradient(180deg, #e7eef8 0, #f7f9fc 360px, var(--bg) 100%);
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  width: min(1720px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #0f172a, #2563eb);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 12px 28px rgba(37, 99, 235, .22);
}

.eyebrow,
.kicker,
.section-label {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.08;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.top-actions,
.button-row,
.preset-row,
.inline-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow);
}

.intro p:last-child {
  max-width: 800px;
  margin: 0;
  color: #334155;
  font-size: 15px;
  line-height: 1.58;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  align-items: start;
}

.sidebar,
.workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
}

.workspace {
  grid-column: 1;
  grid-row: 1;
}

.sidebar {
  grid-column: 2;
  grid-row: 1;
}

.panel,
.chart-card,
.data-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .055);
}

.panel {
  padding: 14px;
}

.panel.compact {
  padding: 12px;
}

.panel-accent {
  border-color: rgba(37, 99, 235, .34);
  background: linear-gradient(180deg, #ffffff 0, #fbfdff 100%);
  box-shadow: 0 16px 34px rgba(37, 99, 235, .1);
}

.panel-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  align-items: start;
  margin-bottom: 13px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #fff;
  background: #111827;
  font-size: 12px;
  font-weight: 900;
}

.field {
  display: block;
  margin: 11px 0;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-weight: 560;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

input::placeholder { color: var(--subtle); }

input:disabled,
select:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #f1f5f9;
}

input:focus,
select:focus {
  border-color: rgba(37, 99, 235, .82);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

input[type="color"] {
  height: 44px;
  padding: 5px;
}

.language-select {
  width: auto;
  min-width: 112px;
  min-height: 42px;
  flex: 0 0 auto;
}

.table-color {
  width: 46px;
  min-width: 46px;
  height: 34px;
  min-height: 34px;
  padding: 3px;
  border-radius: 9px;
}

.two-col,
.three-col {
  display: grid;
  gap: 10px;
}

.two-col { grid-template-columns: 1fr 1fr; }
.three-col { grid-template-columns: 1fr 1fr .86fr; }

.color-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  margin-top: 13px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
}

.color-control-grid .field {
  margin: 0;
}

.mount-color,
.style-preview-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn,
.file-btn,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 10px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s, background .12s;
}

.btn:hover,
.file-btn:hover,
.chip:hover {
  transform: translateY(-1px);
  border-color: #b8c4d4;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .09);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .54;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue), #2f78ff);
}

.btn-primary:hover { background: linear-gradient(135deg, var(--blue-dark), #2563eb); }
.btn-soft { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.btn-danger { color: var(--danger); background: var(--danger-bg); border-color: #ffd1cc; }
.full { width: 100%; }

.form-note {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.sheet-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.example-box {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  overflow: hidden;
}

.example-box summary {
  padding: 10px 12px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.example-table-wrap {
  max-width: 100%;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.example-table {
  min-width: 780px;
  border: 0;
  border-radius: 0;
  font-size: 11px;
}

.example-table th,
.example-table td {
  padding: 8px 9px;
  white-space: nowrap;
}

.preset-row { margin-top: 12px; }

.chip {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 999px;
  color: #334155;
  background: var(--surface-soft);
  font-size: 12px;
}

.toggle-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 13px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-blue);
}

.toggle-row strong {
  display: block;
  font-size: 13px;
}

.toggle-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 28px;
}

.switch input { display: none; }

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, .25);
  transition: transform .18s;
}

.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(18px); }

.tc-box {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.tc-box p {
  margin: 0 0 8px;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 14px;
  font-size: 13px;
  font-weight: 750;
}

.check input {
  width: auto;
  min-height: auto;
}

.lens-preview {
  min-height: 48px;
  margin: 10px 0 12px;
  padding: 11px 12px;
  border: 1px solid #cfe0ff;
  border-radius: 14px;
  background: #f5f9ff;
  color: #334155;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
}

.progress-stack {
  display: grid;
  gap: 10px;
  margin-top: 13px;
}

.progress-row {
  display: grid;
  gap: 6px;
}

.progress-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
}

.progress-row strong {
  color: var(--muted);
  font-size: 11px;
}

.progress-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #60a5fa);
  transition: width .18s ease;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.chart-card {
  position: relative;
  overflow: hidden;
}

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

.chart-toolbar h2 {
  font-size: 19px;
}

.chart-toolbar p:last-child {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.legend-note {
  max-width: 250px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: right;
}

.chart-scroll {
  overflow: hidden;
  padding: 8px;
  background: #fff;
}

#chart {
  display: block;
  width: 100%;
  min-width: 0;
  max-height: calc(100vh - 158px);
  height: auto;
  color-scheme: only light;
  forced-color-adjust: none;
}

#chart *,
.heatmap-wrap,
.heatmap-table,
.heatmap-cell {
  forced-color-adjust: none;
}

.chart-scroll,
.heatmap-wrap,
.heatmap-table,
.heatmap-cell {
  color-scheme: only light;
}

.empty-state {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 300px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
  background: #fff;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.data-card { overflow: hidden; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 12px 0;
}

.tab {
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.tab.active {
  color: #fff;
  background: var(--text);
}

.table-wrap {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
}

.exif-panel {
  display: grid;
  gap: 14px;
  padding: 12px;
}

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

.stat-card {
  min-height: 76px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #f8fbff);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.exif-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}

.muted-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.exif-table-wrap {
  max-height: 300px;
  padding: 0;
}

.heatmap-wrap {
  max-height: 430px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
}

.heatmap-table {
  border: 0;
  border-radius: 0;
  min-width: 900px;
  font-size: 12px;
}

.heatmap-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.heatmap-table th:first-child,
.heatmap-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 230px;
  max-width: 280px;
  background: #fff;
  box-shadow: 1px 0 0 #e9eef5;
}

.heatmap-table th:first-child {
  z-index: 3;
  background: var(--surface-soft);
}

.heatmap-cell {
  min-width: 46px;
  text-align: center;
  color: #0f172a;
  font-size: 11px;
  font-weight: 850;
  background: rgba(37, 99, 235, var(--heat, 0));
}

.heatmap-cell.empty {
  color: transparent;
  background: #f8fafc;
}

.top-focal-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.top-focal-list span {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 850;
}

table {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  border-spacing: 0;
  overflow: hidden;
  background: #fff;
  font-size: 13px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #e9eef5;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: #334155;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }

.empty-row {
  color: var(--muted);
  text-align: center;
}

.small-btn {
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fff;
  color: var(--danger);
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.color-swatch {
  width: 44px;
  height: 22px;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 999px;
}

.style-preview {
  width: 92px;
  height: 24px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 44px));
  border-radius: 14px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, .25);
  font-size: 13px;
  font-weight: 850;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-soft: #172033;
    --surface-blue: #10213d;
    --text: #e5e7eb;
    --muted: #9aa9bd;
    --subtle: #748399;
    --line: #273449;
    --line-strong: #334155;
    --blue: #60a5fa;
    --blue-dark: #3b82f6;
    --danger: #fca5a5;
    --danger-bg: #3b1414;
    --shadow: 0 18px 42px rgba(0, 0, 0, .28);
  }

  html {
    background: linear-gradient(180deg, #111827 0, #0b1120 360px, #090d16 100%);
  }

  .intro {
    background: rgba(17, 24, 39, .84);
  }

  .intro p:last-child,
  .field > span,
  .tc-box p,
  .progress-row > div:first-child,
  .lens-preview,
  .chip,
  .summary-pill,
  th {
    color: var(--muted);
  }

  .panel,
  .chart-card,
  .data-card {
    box-shadow: 0 14px 32px rgba(0, 0, 0, .24);
  }

  .panel-accent,
  .stat-card {
    background: linear-gradient(180deg, #111827 0, #0f172a 100%);
  }

  input,
  select,
  .btn,
  .file-btn,
  .chip,
  .summary-pill,
  .small-btn {
    background: #0f172a;
    color: var(--text);
    border-color: var(--line-strong);
  }

  input:disabled,
  select:disabled {
    background: #182235;
  }

  .btn:hover,
  .file-btn:hover,
  .chip:hover {
    border-color: #526176;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .25);
  }

  .btn-soft {
    color: #bfdbfe;
    background: #172554;
    border-color: #1d4ed8;
  }

  .btn-danger {
    color: #fecaca;
    background: #3b1414;
    border-color: #7f1d1d;
  }

  .color-control-grid,
  .example-box,
  .tc-box,
  .lens-preview,
  .toggle-row {
    background: #0f172a;
    border-color: var(--line);
  }

  .example-box summary {
    color: #93c5fd;
  }

  .switch span {
    background: #475569;
  }

  .switch span::after {
    background: #e5e7eb;
  }

  .chart-toolbar,
  .empty-state {
    background: var(--surface);
  }

  .chart-scroll {
    background: #0f172a;
  }

  table {
    border-color: var(--line);
    background: var(--surface);
  }

  th,
  td {
    border-bottom-color: var(--line);
  }

  .top-focal-list span {
    color: #bfdbfe;
    background: #172554;
  }

  .progress-bar {
    background: #1f2937;
  }

  .heatmap-wrap,
  .heatmap-table {
    border-color: #d9e2ee;
    background: #fff;
  }

  .heatmap-table th {
    color: #334155;
    background: #f6f8fb;
  }

  .heatmap-table th:first-child,
  .heatmap-table td:first-child {
    color: #0f172a;
    background: #fff;
    box-shadow: 1px 0 0 #e9eef5;
  }

  .heatmap-cell {
    color: #0f172a;
  }

  .heatmap-cell.empty {
    background: #f8fafc;
  }
}

@media (min-width: 1181px) {
  .sidebar {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    overflow: auto;
    padding-right: 2px;
  }
}

@media (max-width: 1180px) {
  .topbar,
  .intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary {
    justify-content: flex-start;
  }

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

  .workspace,
  .sidebar {
    grid-column: 1;
  }

  .workspace {
    grid-row: 1;
  }

  .sidebar {
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  h1 {
    font-size: 26px;
  }

  .sidebar,
  .two-col,
  .three-col,
  .color-control-grid {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .button-row,
  .inline-actions {
    width: 100%;
  }

  .top-actions .btn,
  .button-row .btn,
  .inline-actions .btn,
  .file-btn {
    flex: 1 1 140px;
  }

  .chart-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .legend-note {
    max-width: none;
    text-align: left;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .exif-section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
