:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-muted: #eef1ed;
  --text: #1d2421;
  --text-muted: #68716c;
  --border: #d6dcd7;
  --border-strong: #aeb8b1;
  --accent: #0f766e;
  --accent-soft: #d9f1ec;
  --accent-text: #0a544f;
  --warning: #b68105;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --success: #18794e;
  --code-bg: #f8faf8;
  --focus: #0f766e;
  --shadow: 0 10px 30px rgba(30, 42, 35, 0.07);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a18;
  --surface: #202522;
  --surface-muted: #292f2b;
  --text: #edf2ee;
  --text-muted: #aab4ad;
  --border: #39413c;
  --border-strong: #58635c;
  --accent: #37c7b5;
  --accent-soft: #173f3a;
  --accent-text: #88e5d8;
  --warning: #f4c152;
  --danger: #ff8a80;
  --danger-soft: #4c2927;
  --success: #68d391;
  --code-bg: #181c1a;
  --focus: #55d8c7;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

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

button,
select,
input {
  min-height: 38px;
}

button {
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 30%, transparent);
  outline-offset: 1px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
}

.header-inner,
.page-shell,
.site-footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.privacy-state,
.validation-state,
.unit-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 19px;
  line-height: 1;
}

.page-shell {
  padding-block: 42px 58px;
}

.workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 800;
}

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

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.clock {
  margin: 0;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.tool-tabs {
  width: fit-content;
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 3px;
  padding: 3px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
}

.tab-button {
  min-height: 36px;
  padding: 6px 18px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 650;
}

.tab-button:hover {
  color: var(--text);
}

.tab-button.is-active {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: 0 1px 4px rgba(20, 30, 24, 0.09);
}

.tool-panel {
  overflow: hidden;
  min-height: 540px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 12px 9px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.metric-row strong {
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.command-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.command-row button,
.input-command button {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 650;
}

button.quiet {
  border-color: transparent;
  background: transparent;
}

button.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.select-label {
  color: var(--text-muted);
  font-size: 12px;
}

select {
  padding: 5px 28px 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
}

.editor {
  width: 100%;
  min-height: 450px;
  resize: vertical;
  border: 0;
  border-radius: 0;
  background: var(--code-bg);
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.65;
  tab-size: 2;
}

.editor::placeholder {
  color: var(--text-muted);
  opacity: 0.72;
}

.editor:focus {
  outline: 0;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--focus) 32%, transparent);
}

.editor-large {
  display: block;
  min-height: 500px;
  padding: 22px;
}

.json-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 450px;
}

.editor-pane {
  min-width: 0;
  background: var(--code-bg);
}

.editor-pane + .editor-pane {
  border-left: 1px solid var(--border);
}

.editor-pane > label,
.pane-label {
  height: 36px;
  display: flex;
  align-items: center;
  padding-inline: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
}

.editor-pane .editor {
  display: block;
  min-height: 414px;
  padding: 16px;
}

#json-output {
  min-height: 414px;
  max-height: 650px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  color: var(--text);
  background: var(--code-bg);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.placeholder {
  color: var(--text-muted);
  opacity: 0.72;
}

.validation-state[data-state="valid"] {
  color: var(--success);
}

.validation-state[data-state="invalid"] {
  color: var(--danger);
}

.validation-state[data-state="idle"] .status-dot {
  background: var(--border-strong);
}

.validation-state[data-state="invalid"] .status-dot {
  background: var(--danger);
}

.error-message {
  min-height: 35px;
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  color: var(--danger);
  background: var(--surface);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.error-message:empty {
  display: none;
}

.time-panel {
  min-height: 0;
}

.now-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.5fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.now-strip > div {
  min-width: 0;
  padding: 20px 24px;
}

.now-strip > div + div {
  border-left: 1px solid var(--border);
}

.now-strip strong,
.value-button {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.value-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.converter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.converter-section {
  min-width: 0;
  padding: 24px;
}

.converter-section + .converter-section {
  border-left: 1px solid var(--border);
}

.section-title-row {
  min-height: 40px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title-row h2 {
  margin: 0;
  font-size: 17px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
}

.mode-switch button {
  min-height: 30px;
  padding: 3px 10px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
}

.mode-switch button.is-active {
  background: var(--surface);
  color: var(--accent-text);
}

.input-command {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.input-command input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--code-bg);
  font-variant-numeric: tabular-nums;
}

.result-list {
  margin: 22px 0 0;
  border-top: 1px solid var(--border);
}

.result-list > div {
  min-height: 48px;
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.result-list dt {
  color: var(--text-muted);
  font-size: 12px;
}

.result-list dd {
  min-width: 0;
  margin: 0;
}

.result-list button {
  width: 100%;
  min-height: 34px;
  padding: 4px 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-footer {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100% - 44px));
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.gallery-panel {
  min-height: 0;
  overflow: visible;
  padding-top: 16px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.gallery-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.gallery-heading h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.4;
}

.photo-count, .photo-number {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.photo-item {
  min-width: 0;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.photo-open {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface-muted);
  cursor: zoom-in;
}

.photo-open img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 220ms ease;
}

.photo-open:hover img { transform: scale(1.025); }
.photo-open:focus-visible { outline-offset: -4px; }
.photo-item figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 14px;
  font-size: 14px;
  font-weight: 600;
}

body.photo-is-open { overflow: hidden; }
.photo-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #141715;
  color: #f5f7f5;
}
.photo-viewer[open] { display: grid; grid-template-rows: 62px minmax(0, 1fr) 56px; }
.photo-viewer::backdrop { background: #141715; }
.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.viewer-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #ffffff35;
  border-radius: 5px;
  background: #141715cc;
  color: white;
}
.viewer-button:hover { background: #39413b; border-color: #ffffff80; }
.viewer-button img { filter: invert(1); }
.viewer-stage { position: relative; min-height: 0; display: flex; justify-content: center; align-items: center; }
#viewer-image { display: block; width: 100%; height: 100%; object-fit: contain; touch-action: pan-y; }
.viewer-prev, .viewer-next { position: absolute; top: calc(50% - 22px); }
.viewer-prev { left: 20px; }
.viewer-next { right: 20px; }
.viewer-caption { margin: 0; padding: 16px; text-align: center; font-size: 14px; }

@media (max-width: 900px) {
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
@media (max-width: 430px) {
  .photo-item figcaption { padding: 11px 10px; font-size: 13px; }
  .viewer-toolbar { padding-inline: 12px; }
  .viewer-prev { left: 8px; }
  .viewer-next { right: 8px; }
}

@media (max-width: 760px) {
  .header-inner,
  .page-shell,
  .site-footer {
    width: min(100% - 24px, 1180px);
  }

  .privacy-state {
    display: none;
  }

  .page-shell {
    padding-block: 26px 38px;
  }

  .workspace-heading {
    align-items: start;
    margin-bottom: 18px;
  }

  h1 {
    font-size: 24px;
  }

  .clock {
    padding-top: 21px;
    font-size: 12px;
  }

  .tool-tabs {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tab-button {
    padding-inline: 8px;
  }

  .tool-panel {
    min-height: 0;
  }

  .panel-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .metric-row {
    justify-content: space-between;
    gap: 8px;
  }

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

  .command-row button {
    min-width: 0;
    padding-inline: 5px;
    white-space: nowrap;
  }

  #panel-json .command-row {
    grid-template-columns: auto 48px repeat(4, minmax(0, 1fr));
  }

  .editor-large {
    min-height: 480px;
    padding: 16px;
  }

  .json-workspace {
    grid-template-columns: 1fr;
  }

  .editor-pane + .editor-pane {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .editor-pane .editor,
  #json-output {
    min-height: 300px;
  }

  .now-strip,
  .converter-grid {
    grid-template-columns: 1fr;
  }

  .now-strip > div {
    padding: 17px 18px;
  }

  .now-strip > div + div,
  .converter-section + .converter-section {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .now-strip strong,
  .value-button {
    font-size: 20px;
  }

  .converter-section {
    padding: 20px 16px;
  }

  .result-list > div {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .site-footer {
    min-height: 64px;
  }
}

@media (max-width: 430px) {
  .workspace-heading {
    display: block;
  }

  .clock {
    padding-top: 6px;
  }

  .command-row,
  #panel-json .command-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .select-label {
    display: flex;
    align-items: center;
  }

  .section-title-row {
    align-items: center;
  }

  .result-list button {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
