:root {
  color-scheme: dark;
  --canvas: #09111f;
  --surface: #101b2b;
  --surface-soft: #16243a;
  --line: rgba(163, 190, 222, 0.15);
  --ink: #edf4ff;
  --muted-ink: #8fa6c1;
  --accent: #6aa6e8;
  --accent-soft: rgba(106, 166, 232, 0.13);
  --accent-ink: #9bc8f2;
  --shell: rgba(94, 137, 191, 0.06);
  --hairline: rgba(176, 203, 232, 0.11);
  --ambient-shadow: 0 30px 90px rgba(2, 11, 27, 0.38);
  --button-bg: #72aceb;
  --button-ink: #071321;
  --success: #67c99b;
  --danger: #e58a86;
  --ui-sans: "Geist", "Plus Jakarta Sans", "Avenir Next", "Segoe UI", "PingFang TC", sans-serif;
  --ui-mono: "Geist Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --canvas: #f2f6fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: rgba(35, 73, 116, 0.13);
  --ink: #15263b;
  --muted-ink: #61758c;
  --accent: #2e6eae;
  --accent-soft: rgba(46, 110, 174, 0.10);
  --accent-ink: #245f9c;
  --shell: rgba(42, 88, 141, 0.045);
  --hairline: rgba(38, 78, 124, 0.10);
  --ambient-shadow: 0 30px 90px rgba(35, 72, 116, 0.11);
  --button-bg: #2e6eae;
  --button-ink: #ffffff;
  --success: #237a57;
  --danger: #b64e4b;
}

* {
  box-sizing: border-box;
}

:where(button, input, select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 40px 20px 48px;
  background:
    radial-gradient(circle at 10% -8%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 34rem),
    radial-gradient(circle at 92% 12%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 26rem),
    var(--canvas);
  color: var(--ink);
  font-family: var(--ui-sans);
  line-height: 1.6;
  transition: background-color 160ms ease, color 160ms ease;
}

.wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}

header {
  margin-bottom: 32px;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 24%, transparent);
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.sub {
  margin: 8px 0 0 20px;
  color: var(--muted-ink);
  font-size: 13px;
}

.theme-toggle {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface);
}

.theme-toggle button {
  width: auto;
  height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted-ink);
  font: 600 11px/1 var(--ui-sans);
  cursor: pointer;
}

.theme-toggle button.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 16px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface);
}

.tab {
  min-width: 0;
  padding: 12px 10px 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted-ink);
  font-size: 12px;
  font-family: var(--ui-sans);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background-color 320ms cubic-bezier(0.32, 0.72, 0, 1), color 320ms cubic-bezier(0.32, 0.72, 0, 1), border-color 320ms cubic-bezier(0.32, 0.72, 0, 1);
}

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

.tab:hover:not(.active) {
  background: var(--surface-soft);
  color: var(--ink);
}

.tab.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent-ink);
  box-shadow: none;
}

.card {
  display: none;
  padding: 30px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--ink) 5%, transparent);
}

.card.active {
  display: block;
  animation: card-in 320ms cubic-bezier(0.32, 0.72, 0, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.field {
  margin-bottom: 22px;
}

.field label,
.result-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

input[type="number"],
input[type="datetime-local"],
select {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: var(--surface-soft);
  color: var(--ink);
  font-family: var(--ui-mono);
  font-size: 14px;
  box-shadow: none;
  transition: border-color 150ms ease, background-color 150ms ease;
}

select {
  font-family: var(--ui-sans);
}

input:focus,
select:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.row {
  display: flex;
  gap: 16px;
}

.row > * {
  flex: 1;
  min-width: 0;
}

.tz-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.quick-tz {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 10px;
}

.quick-tz button {
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--accent-ink);
  font-family: var(--ui-mono);
  font-size: 11px;
  cursor: pointer;
}

.quick-tz button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.quick-tz .empty-hint,
.hint {
  padding: 0;
  color: var(--muted-ink);
  font-size: 11px;
}

.star-btn {
  flex: 0 0 46px;
  width: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted-ink);
  font-size: 16px;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.star-btn:hover,
.star-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.unit-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  min-width: 250px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.unit-toggle button {
  padding: 7px 12px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted-ink);
  font: 600 11px/1.2 var(--ui-sans);
  cursor: pointer;
}

.unit-toggle button:last-child {
  border-right: 0;
}

.unit-toggle button.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.btn {
  width: 100%;
  min-height: 46px;
  padding: 11px 16px;
  border: 1px solid var(--button-bg);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--button-ink);
  font: 650 13px/1 var(--ui-sans);
  box-shadow: 0 8px 26px color-mix(in srgb, var(--accent) 18%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: opacity 320ms cubic-bezier(0.32, 0.72, 0, 1), transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
}

.btn:hover {
  filter: none;
  opacity: 1;
  box-shadow: 0 12px 32px color-mix(in srgb, var(--accent) 25%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}

.btn:active {
  transform: scale(0.99);
}

.btn.secondary {
  display: block;
  width: auto;
  min-height: 32px;
  margin: 8px auto 0;
  padding: 6px 8px;
  border-color: transparent;
  background: transparent;
  color: var(--muted-ink);
  font-weight: 550;
}

.btn.secondary:hover {
  color: var(--ink);
  opacity: 1;
}

.result {
  margin-top: 26px;
  padding: 22px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.result-label {
  margin-bottom: 12px;
}

.subline {
  color: var(--muted-ink);
  font-family: var(--ui-mono);
  font-size: 12px;
  line-height: 2;
}

.subline b {
  color: var(--ink);
  font-weight: 600;
}

.subline .tz {
  color: var(--accent-ink);
}

.board {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 12px;
}

.board-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chip,
.chip.sep {
  min-width: 22px;
  padding: 4px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--ui-mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}

.chip::after {
  display: none;
}

.chip.flash {
  animation: none;
}

footer {
  margin-top: 20px;
  color: var(--muted-ink);
  font-size: 11px;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: start;
  gap: 18px;
}

.tool-stack,
.clock-panel {
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  background: var(--shell);
  box-shadow: var(--ambient-shadow), inset 0 1px 0 color-mix(in srgb, var(--ink) 4%, transparent);
}

.clock-panel {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 6px;
}

.clock-section {
  padding: 22px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--surface);
}

.clock-label {
  margin: 0 0 14px;
  color: var(--muted-ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.clock-time {
  display: block;
  color: var(--ink);
  font-family: var(--ui-mono);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 560;
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.clock-zone {
  margin: 10px 0 0;
  color: var(--accent-ink);
  font-size: 11px;
}

.favorite-clocks {
  display: grid;
  gap: 0;
}

.favorite-clock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--hairline);
}

.favorite-clock:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.favorite-clock:first-child {
  padding-top: 0;
}

.favorite-clock span {
  display: grid;
  min-width: 0;
}

.favorite-clock b {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-clock small {
  color: var(--muted-ink);
  font-size: 9px;
}

.favorite-clock time {
  color: var(--ink);
  font-family: var(--ui-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.empty-clock {
  margin: 0;
  color: var(--muted-ink);
  font-size: 11px;
}

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

.result-heading .result-label {
  margin: 0;
}

.copy-all,
.copy-btn,
.swap-btn {
  border: 0;
  background: transparent;
  color: var(--accent-ink);
  font: 650 10px/1 var(--ui-sans);
  cursor: pointer;
  transition: color 280ms cubic-bezier(0.32, 0.72, 0, 1), transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
}

.copy-all:hover,
.copy-btn:hover,
.swap-btn:hover {
  color: var(--accent);
  transform: translateY(-1px);
}

.copy-all.copied,
.copy-btn.copied {
  color: var(--success);
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--hairline);
}

.result-row:last-child {
  border-bottom: 0;
}

.result-row > div {
  display: grid;
  grid-template-columns: minmax(90px, 0.35fr) minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
}

.result-key {
  color: var(--muted-ink);
  font-family: var(--ui-sans);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-value {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: var(--ui-mono);
  font-size: 11px;
}

.result-row.primary .result-value {
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
}

.field-error {
  display: none;
  margin-top: 7px;
  color: var(--danger);
  font-size: 11px;
}

.field-error.visible {
  display: block;
}

.swap-wrap {
  display: flex;
  flex: 0 0 52px;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 22px;
}

.swap-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--surface-soft);
}

.swap-btn:active {
  transform: scale(0.96);
}

@media (max-width: 640px) {
  body {
    padding: 24px 12px 36px;
  }

  header {
    margin-bottom: 24px;
  }

  .header-row {
    gap: 12px;
  }

  .sub {
    max-width: 230px;
    margin-left: 0;
  }

  .theme-toggle button {
    padding: 0 7px;
  }

  .tabs {
    display: flex;
    overflow-x: auto;
  }

  .tab {
    flex: 1 0 132px;
    white-space: nowrap;
  }

  .card {
    padding: 22px 16px;
  }

  .row {
    display: block;
  }

  .unit-toggle {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 900px) {
  .wrap {
    max-width: 720px;
  }

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

  .clock-panel {
    position: static;
    grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  }

  .favorite-clocks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
  }
}

@media (max-width: 640px) {
  .tool-stack,
  .clock-panel {
    padding: 4px;
    border-radius: 16px;
  }

  .clock-panel {
    grid-template-columns: 1fr;
  }

  .favorite-clocks {
    grid-template-columns: 1fr;
  }

  .swap-wrap {
    align-items: center;
    padding: 0 0 18px;
  }

  .swap-btn {
    width: 100%;
    height: 36px;
    border-radius: 8px;
  }

  .result-row > div {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

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