:root {
  --bg: #e7ecf3;
  --panel: #e7ecf3;
  --text: #1b2430;
  --muted: #5e6a79;
  --accent: #ff8b5c;
  --accent-text: #2b140a;
  --operator: #8ea7ff;
  --danger: #ff6d6d;
  --shadow-dark: #c3c9d2;
  --shadow-light: #f8fbff;
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 15%, #f3f7ff 0%, transparent 40%),
    radial-gradient(circle at 80% 85%, #dfe8ff 0%, transparent 35%),
    linear-gradient(165deg, #edf2f8 0%, #dce4ee 100%);
  display: grid;
  place-items: center;
  padding: 20px;
}

body.page-home {
  place-items: start center;
}

.app-shell {
  width: min(980px, 100%);
  display: grid;
  gap: 20px;
}

.app-frame {
  width: min(1180px, 100%);
  grid-template-rows: auto 1fr auto;
}

.frame-header {
  margin-bottom: 2px;
  /* position: sticky; */
  top: 20px;
  z-index: 20;
}

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

.frame-sidebar {
  background: var(--panel);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light);
  display: grid;
  gap: 14px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 1.02rem;
}

.sidebar-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.tab-nav {
  display: grid;
  gap: 10px;
}

.tool-tab {
  border: 0;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #2c3649;
  background: var(--panel);
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  cursor: pointer;
}

.tool-tab.active {
  color: #1e2a41;
  background: linear-gradient(135deg, #dfe7ff 0%, #cad8ff 100%);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}

.tool-tab:focus-visible {
  outline: 3px solid #2f5eff;
  outline-offset: 2px;
}

.frame-main {
  min-width: 0;
}

.tool-panel[hidden] {
  display: none !important;
}

.placeholder-panel {
  background: var(--panel);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light);
  display: grid;
  gap: 10px;
}

.placeholder-panel h2 {
  margin: 0;
}

.placeholder-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.placeholder-note {
  font-size: 0.88rem;
  color: #41506a;
}

.time-card {
  background: var(--panel);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light);
  display: grid;
  gap: 14px;
}

.time-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.time-card-head h2 {
  margin: 0;
}

.time-refresh {
  border: 0;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #20345f;
  background: linear-gradient(135deg, #dfe7ff 0%, #cad8ff 100%);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  cursor: pointer;
}

.time-refresh:active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.time-refresh:focus-visible {
  outline: 3px solid #2f5eff;
  outline-offset: 2px;
}

.time-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.time-row {
  margin: 0;
  border-radius: var(--radius-lg);
  padding: 14px;
  background: #eaf0f8;
  box-shadow: inset 5px 5px 10px #cad1dc, inset -5px -5px 10px #f8fbff;
  display: grid;
  gap: 6px;
}

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

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

.local-time-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.local-time-item {
  margin: 0;
  border-radius: var(--radius-md);
  padding: 10px;
  background: #f5f8fc;
  box-shadow: inset 3px 3px 6px #cad1dc, inset -3px -3px 6px #f8fbff;
  align-self: start;
}

.local-time-item h3{
  margin: 0;
  font-size: 0.76rem;
  color: #4d5b70;
}

.server-time-value {
  font-weight: 400;
  color: #1f2a3a;
}

.local-time-value {
  font-weight: 700;
  color: #253248;
}

.time-value {
  margin: 0;
  display: grid;
  gap: 4px;
}

.time-date {
  font-size: clamp(0.82rem, 3vw, 1rem);
  font-weight: 600;
  color: #5b6980;
  letter-spacing: 0.03em;
}

.time-clock {
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.server-time-value .time-clock {
  font-size: clamp(4rem, 16vw, 10rem);
  font-weight: 400;
}

.local-time-value .time-clock {
  font-size: clamp(2rem, 5vw, 3rem);
}

.local-time-value .time-date {
  display: none;
}

.timezone-value {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #253248;
}

.timezone-select {
  width: 100%;
  margin-top: 6px;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.88rem;
  color: #253248;
  background: #eef3fb;
  box-shadow: inset 2px 2px 5px #cad1dc, inset -2px -2px 5px #f8fbff;
}

.timezone-select:focus-visible {
  outline: 3px solid #2f5eff;
  outline-offset: 2px;
}

.time-sub {
  margin: 0;
  color: #4f607a;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.time-meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.time-meta div {
  border-radius: var(--radius-md);
  background: #eaf0f8;
  box-shadow: inset 3px 3px 6px #cad1dc, inset -3px -3px 6px #f8fbff;
  padding: 10px;
}

.time-meta dt {
  font-size: 0.76rem;
  color: #5f6e81;
  margin-bottom: 4px;
}

.time-meta dd {
  margin: 0;
  color: #253248;
  font-size: 0.9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.time-status {
  margin: 0;
  font-size: 0.84rem;
  color: #3f4d66;
}

.time-status.is-error {
  color: #8d1f1f;
}

.frame-footer {
  border-radius: var(--radius-xl);
  padding: 12px 16px;
  background: var(--panel);
  box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light);
}

.frame-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

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

.history-panel {
  background: var(--panel);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light);
  max-height: 620px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-header h2 {
  margin: 0;
  font-size: 1rem;
}

.history-header span {
  color: var(--muted);
  font-size: 0.82rem;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-order-toggle {
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #2d3a58;
  background: linear-gradient(135deg, #e2e9ff 0%, #ccd9ff 100%);
  box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
  cursor: pointer;
}

.history-order-toggle:active {
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

.history-order-toggle:focus-visible {
  outline: 3px solid #2f5eff;
  outline-offset: 2px;
}

.history-order-icon {
  width: 1rem;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1;
}

.history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.history-item {
  border-radius: 12px;
  padding: 10px 12px;
  background: #eaf0f8;
  box-shadow: inset 3px 3px 6px #cad1dc, inset -3px -3px 6px #f8fbff;
}

.history-expression {
  color: #5d6b7c;
  font-size: 0.82rem;
  word-break: break-word;
}

.history-result {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 700;
  color: #273240;
  word-break: break-word;
}

.topbar {
  border-radius: var(--radius-xl);
  padding: 18px 22px;
  background: var(--panel);
  box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.title-wrap h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2.7vw, 1.55rem);
  letter-spacing: 0.02em;
}

.title-wrap p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.tool-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tool-chip {
  border: 0;
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.86rem;
  color: #394352;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  background: var(--panel);
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

.tool-chip.active {
  color: #1f242c;
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}

.tool-chip.is-disabled {
  color: #6c7785;
  opacity: 0.75;
  cursor: not-allowed;
}

/* 页头标题链接 */
.title-link {
  color: inherit;
  text-decoration: none;
}

/* 独立页下拉菜单 */
.tool-chip-group {
  position: relative;
}

.tool-chip-expand {
  cursor: pointer;
  gap: 6px;
}

.expand-caret {
  display: inline-block;
  transition: transform 0.2s ease;
  font-style: normal;
}

.tool-chip-expand[aria-expanded="true"] .expand-caret {
  transform: rotate(180deg);
}

.standalone-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: 8px 8px 20px var(--shadow-dark), -8px -8px 20px var(--shadow-light);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}

.standalone-menu[hidden] {
  display: none;
}

.menu-item {
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.86rem;
  color: #394352;
  text-decoration: none;
  display: block;
  white-space: nowrap;
}

a.menu-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

.menu-item.active {
  color: var(--accent-text);
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.menu-item.is-disabled {
  color: #6c7785;
  opacity: 0.75;
  cursor: not-allowed;
}

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

.tool-card {
  background: var(--panel);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light);
  display: grid;
  gap: 10px;
}

.tool-card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.tool-card.is-muted {
  opacity: 0.82;
}

.tool-link {
  justify-self: start;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #213154;
  text-decoration: none;
  background: linear-gradient(135deg, #dfe7ff 0%, #cad8ff 100%);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}

.tool-link.is-disabled {
  color: #677386;
  background: linear-gradient(135deg, #e7e9ee 0%, #d7dbe3 100%);
  cursor: not-allowed;
}

.calculator {
  width: min(420px, 100%);
  margin-inline: auto;
  background: var(--panel);
  border-radius: var(--radius-xl);
  padding: 20px;
  position: relative;
  box-shadow: 14px 14px 28px var(--shadow-dark), -14px -14px 28px var(--shadow-light);
}

.calc-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.shortcut-help-toggle {
  border: 0;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #2a3555;
  background: linear-gradient(135deg, #e2e9ff 0%, #cdd9ff 100%);
  box-shadow: 5px 5px 9px var(--shadow-dark), -5px -5px 9px var(--shadow-light);
  cursor: pointer;
}

.shortcut-help-toggle:active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.shortcut-help-toggle:focus-visible {
  outline: 3px solid #2f5eff;
  outline-offset: 2px;
}

.screen {
  padding: 14px 14px 12px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  min-height: 110px;
  background: #e2e8f1;
  box-shadow: inset 7px 7px 12px #c2c8d2, inset -7px -7px 12px #f8fbff;
  display: grid;
  align-content: end;
  gap: 8px;
}

.expression {
  min-height: 20px;
  text-align: right;
  color: #5f6e7f;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.result {
  text-align: right;
  font-size: clamp(1.9rem, 8vw, 2.55rem);
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

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

.key {
  border: 0;
  border-radius: var(--radius-md);
  min-height: 54px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #212a36;
  background: var(--panel);
  box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
  transition: transform 120ms ease, box-shadow 120ms ease;
  cursor: pointer;
  user-select: none;
}

.key:hover {
  filter: brightness(0.92);
}

.key:active,
.key.active {
  transform: translateY(1px);
  box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
}

.key.operator {
  color: #243a7d;
  background: linear-gradient(135deg, #dfe7ff 0%, #cad8ff 100%);
}

.key.func {
  color: #1a5c3a;
  background: linear-gradient(135deg, #d6f5e6 0%, #b2eacc 100%);
  font-size: 0.9em;
}

.key-placeholder {
  display: block;
}

.key.action {
  color: #5a2020;
  background: linear-gradient(135deg, #ffd7d7 0%, #ffbaba 100%);
}

.key.equals {
  color: var(--accent-text);
  background: linear-gradient(135deg, #ffd1b8 0%, #ff9f73 100%);
}

.key.zero {
  grid-column: span 1;
}

.key:focus-visible {
  outline: 3px solid #2f5eff;
  outline-offset: 2px;
}

.hint {
  margin-top: 13px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.shortcut-help {
  position: absolute;
  inset: 16px;
  border-radius: var(--radius-lg);
  padding: 14px;
  z-index: 3;
  background: rgba(233, 239, 248, 0.97);
  box-shadow: inset 7px 7px 12px #c2c8d2, inset -7px -7px 12px #f8fbff;
  overflow: auto;
}

.shortcut-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.shortcut-help-header h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.shortcut-help-close {
  border: 0;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #4a1f1f;
  background: linear-gradient(135deg, #ffd8d8 0%, #ffc0c0 100%);
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
  cursor: pointer;
}

.shortcut-help-close:focus-visible {
  outline: 3px solid #2f5eff;
  outline-offset: 2px;
}

.shortcut-help-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.shortcut-help-list li {
  background: #edf2fb;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.88rem;
  line-height: 1.35;
  box-shadow: inset 3px 3px 6px #ced4de, inset -3px -3px 6px #f8fbff;
}

.shortcut-help-list kbd {
  font-family: inherit;
  border-radius: 6px;
  padding: 1px 6px;
  margin-right: 6px;
  font-size: 0.8rem;
  background: #d5def0;
  box-shadow: inset 2px 2px 3px #b7c0d0, inset -2px -2px 3px #edf3ff;
}

@media (max-width: 680px) {
  .topbar {
    padding: 16px;
  }

  .tool-chip {
    font-size: 0.8rem;
    padding: 8px 12px;
  }

  .calculator {
    padding: 16px;
  }

  .shortcut-help {
    inset: 12px;
    padding: 12px;
  }

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

  .time-grid,
  .time-meta {
    grid-template-columns: 1fr;
  }

  .time-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .tab-nav {
    grid-template-columns: 1fr;
  }

  .tool-tab {
    text-align: left;
  }

  .key {
    min-height: 48px;
  }

  .key.equals {
    min-height: 48px;
  }
}

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

  .frame-body {
    grid-template-columns: 1fr;
  }

  .tab-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tool-tab {
    text-align: center;
    font-size: 0.84rem;
  }

  .calc-layout {
    grid-template-columns: 1fr;
  }

  .history-panel {
    max-height: 320px;
  }

  .calculator {
    width: 100%;
  }
}

/* ── 剪贴板分词复制 ─────────────────────────────── */

.cs-card {
  background: var(--panel);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light);
  display: grid;
  gap: 14px;
}

.cs-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.cs-head h2 {
  margin: 0;
}

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

.cs-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  color: #20345f;
  background: var(--panel);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  touch-action: manipulation;
}

.cs-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

.cs-btn:not(:disabled):active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.cs-btn:focus-visible {
  outline: 3px solid #2f5eff;
  outline-offset: 2px;
}

.cs-btn-primary {
  color: #1e2a41;
  background: linear-gradient(135deg, #dfe7ff 0%, #cad8ff 100%);
}

.cs-btn-danger:not(:disabled) {
  color: #5a0f0f;
  background: linear-gradient(135deg, #ffe0e0 0%, #ffc8c8 100%);
}

.cs-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.cs-char-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  /* 禁止滑动时触发页面滚动 */
  touch-action: none;
}

.cs-char-btn {
  min-width: 2em;
  min-height: 2em;
  padding: 2px 4px;
  border: 0;
  border-radius: 5px;
  font-size: 1.1rem;
  line-height: 1.5;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.cs-char-btn:focus-visible {
  outline: 3px solid #2f5eff;
  outline-offset: 2px;
}

.cs-char-btn.cs-char-selected {
  background: linear-gradient(135deg, #ff9e6e 0%, #ff7a40 100%);
  color: #2b140a;
  border-radius: 5px;
}

.cs-char-space {
  color: var(--muted);
  font-size: 0.9rem;
}

.cs-status {
  margin: 0;
  font-size: 0.84rem;
  color: #3f4d66;
  min-height: 1.2em;
}

.cs-status-error {
  color: #8d1f1f;
}
