:root {
  color-scheme: light;
  font-family: "IBM Plex Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  --page: #f3f5f2;
  --surface: #ffffff;
  --surface-muted: #eef2ee;
  --surface-code: #f7f9f7;
  --ink: #18211c;
  --muted: #5d6962;
  --border: #cbd4cd;
  --border-strong: #98a69d;
  --primary: #126b43;
  --primary-hover: #0d5737;
  --primary-soft: #dcefe5;
  --focus: #1769aa;
  --danger: #b42318;
  --danger-soft: #fff1ef;
  --accent: #a84f12;
  --shadow: 0 12px 32px rgb(24 33 28 / 8%);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--page);
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  background: var(--page);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

button,
input {
  min-height: 44px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.time-zone-suggestions button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  display: flex;
  width: min(1180px, calc(100% - 32px));
  min-height: 76px;
  margin: 0 auto;
  align-items: center;
  gap: 26px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--primary);
  border-radius: 5px;
  background: var(--primary);
  color: #ffffff;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 1rem;
}

.product-title {
  min-width: 0;
  padding-left: 26px;
  border-left: 1px solid var(--border);
}

.product-title span {
  display: block;
  margin-bottom: 2px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.product-title h1 {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 650;
  line-height: 1.25;
}

.app-main {
  width: min(1180px, calc(100% - 32px));
  margin: 30px auto 20px;
}

.module-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(132px, 1fr));
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.module-tabs button {
  min-width: 132px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  transition: background-color 180ms ease-out, color 180ms ease-out;
}

.module-tabs button[aria-selected="true"] {
  background: var(--primary);
  color: #ffffff;
}

#identifier-workbench,
#time-workbench {
  min-width: 0;
}

.module-tabs + section > .mode-tabs {
  margin-top: 14px;
}

.mode-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(112px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.mode-tabs button {
  min-width: 112px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  transition: background-color 180ms ease-out, color 180ms ease-out;
}

.mode-tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(24 33 28 / 12%);
}

.workbench {
  display: grid;
  min-width: 0;
  min-height: 540px;
  margin-top: 14px;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.control-pane {
  min-width: 0;
  padding: 28px;
  border-right: 1px solid var(--border);
  background: #fbfcfb;
}

form {
  display: grid;
  gap: 26px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
.field-group > label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
}

.kind-control {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.kind-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.kind-control label {
  display: grid;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px;
  place-items: center;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 650;
  text-align: center;
  transition: background-color 180ms ease-out, color 180ms ease-out;
}

.kind-control input:checked + label {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgb(24 33 28 / 12%);
}

.kind-control input:focus-visible + label {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.field-group {
  min-width: 0;
}

.stepper {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stepper:focus-within {
  border-color: var(--focus);
}

.stepper input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-weight: 600;
  text-align: center;
  appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.stepper .icon-button {
  border: 0;
  border-radius: 0;
}

#identifier-input,
#time-instant-input,
#time-zone-input,
#time-local-input,
#time-resolve-zone {
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
}

#identifier-input::placeholder,
#time-instant-input::placeholder,
#time-zone-input::placeholder,
#time-local-input::placeholder,
#time-resolve-zone::placeholder {
  color: var(--muted);
}

.primary-button {
  display: inline-flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  transition: background-color 180ms ease-out, border-color 180ms ease-out;
}

.primary-button:not(:disabled):hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.primary-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: background-color 180ms ease-out, border-color 180ms ease-out, color 180ms ease-out;
}

.icon-button:not(:disabled):hover {
  border-color: var(--border-strong);
  background: var(--surface-muted);
  color: var(--primary);
}

.inline-error {
  margin: -12px 0 -8px;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.45;
}

.result-pane {
  min-width: 0;
  padding: 26px 28px 28px;
}

.result-toolbar {
  display: flex;
  min-width: 0;
  min-height: 48px;
  margin-bottom: 18px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.result-toolbar h2 {
  margin: 0 0 3px;
  font-size: 1rem;
  font-weight: 700;
}

.result-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

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

.generate-output {
  display: block;
  width: 100%;
  min-width: 0;
  height: 414px;
  padding: 16px;
  resize: none;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-code);
  color: var(--ink);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  white-space: pre;
}

.inspection-output {
  min-height: 414px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-code);
}

.inspection-output div {
  display: grid;
  min-width: 0;
  min-height: 68px;
  padding: 14px 16px;
  grid-template-columns: minmax(110px, 0.28fr) minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.inspection-output div:last-child {
  border-bottom: 0;
}

.inspection-output dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.inspection-output dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.84rem;
}

.time-workbench-panel {
  min-height: 610px;
}

.time-kind-control label {
  min-height: 52px;
  line-height: 1.25;
}

.time-zone-field {
  position: relative;
}

.time-zone-entry {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.time-zone-suggestions {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 224px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  list-style: none;
}

.time-zone-suggestions [role="option"] {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  text-align: left;
}

.time-zone-suggestions [role="option"]:hover,
.time-zone-suggestions [role="option"][aria-selected="true"] {
  background: var(--surface-muted);
  color: var(--primary);
}

.time-selected-zones {
  display: grid;
  height: 230px;
  margin: -12px 0 0;
  padding: 0;
  align-content: start;
  grid-auto-rows: 45px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-code);
  list-style: none;
}

.time-selected-zones li {
  display: grid;
  min-width: 0;
  height: 45px;
  padding-left: 12px;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
}

.time-selected-zones li:last-child {
  border-bottom: 0;
}

.time-selected-zones span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.time-selected-zones .zone-remove {
  width: 44px;
  height: 44px;
  border-width: 0 0 0 1px;
  border-radius: 0;
}

.time-primary {
  display: grid;
  margin: 0 0 18px;
  padding: 14px 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
}

.time-primary div {
  min-width: 0;
}

.time-primary dt,
.resolution-candidate dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.time-primary dd,
.resolution-candidate dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
}

.time-result-table {
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.time-result-table table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.time-result-table th,
.time-result-table td {
  min-width: 0;
  padding: 12px 10px;
  overflow-wrap: anywhere;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.time-result-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.time-result-table td {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
}

.time-result-table tr:last-child td {
  border-bottom: 0;
}

.time-result-table th:nth-child(1) { width: 24%; }
.time-result-table th:nth-child(2) { width: 31%; }
.time-result-table th:nth-child(3) { width: 14%; }
.time-result-table th:nth-child(4) { width: 19%; }
.time-result-table th:nth-child(5) { width: 12%; }

.time-resolution-output {
  display: grid;
  gap: 14px;
}

.resolution-status {
  width: fit-content;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: #fff7ed;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.resolution-candidate {
  display: grid;
  margin: 0;
  padding: 14px 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-code);
}

.resolution-candidate div {
  min-width: 0;
}

.status-bar {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-bar p {
  margin: 0;
}

#status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

body[data-ready="true"] #status-indicator {
  background: var(--primary);
}

@media (max-width: 820px) {
  .header-inner,
  .app-main {
    width: min(100% - 24px, 680px);
  }

  .header-inner {
    min-height: 72px;
    gap: 16px;
  }

  .product-title {
    padding-left: 16px;
  }

  .product-title h1 {
    font-size: 1.05rem;
  }

  .product-title span {
    font-size: 0.64rem;
  }

  .app-main {
    margin-top: 22px;
  }

  .mode-tabs {
    display: grid;
    width: 100%;
  }

  .module-tabs {
    display: grid;
    width: 100%;
  }

  .module-tabs button {
    min-width: 0;
  }

  .mode-tabs button {
    min-width: 0;
  }

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

  .control-pane {
    padding: 22px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .result-pane {
    padding: 22px;
  }

  .generate-output,
  .inspection-output {
    min-height: 300px;
    height: 300px;
  }

  .time-primary {
    grid-template-columns: minmax(0, 1fr);
  }

  .time-result-table {
    border: 0;
    overflow: visible;
  }

  .time-result-table table,
  .time-result-table tbody,
  .time-result-table tr,
  .time-result-table td {
    display: block;
    width: 100%;
  }

  .time-result-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .time-result-table tbody {
    display: grid;
    gap: 12px;
  }

  .time-result-table tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-code);
  }

  .time-result-table td {
    display: grid;
    padding: 10px 12px;
    grid-template-columns: minmax(92px, 0.4fr) minmax(0, 1fr);
    gap: 10px;
  }

  .time-result-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-family: "IBM Plex Sans", Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
  }
}

@media (max-width: 430px) {
  .header-inner {
    width: calc(100% - 24px);
  }

  .brand {
    gap: 7px;
    font-size: 0.82rem;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .product-title {
    min-width: 0;
  }

  .product-title h1 {
    overflow-wrap: anywhere;
  }

  .control-pane,
  .result-pane {
    padding: 18px;
  }

  .kind-control label {
    padding: 0 4px;
    font-size: 0.74rem;
  }

  .time-kind-control {
    grid-template-columns: minmax(0, 1fr);
  }

  .resolution-candidate {
    grid-template-columns: minmax(0, 1fr);
  }

  .result-toolbar {
    align-items: center;
  }

  .inspection-output div {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
}

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