:root {
  color-scheme: light;
  --ink: #17191e;
  --muted: #626a77;
  --line: #c7ced8;
  --page: #f2f4f8;
  --paper: #ffffff;
  --primary: #1557ff;
  --accent: #dfff00;
  --warm: #ff6b4a;
  --soft: #eef2f7;
  --shadow-offset: 7px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

body[data-theme="coral"] {
  --primary: #e8432f;
  --accent: #ffb3d1;
  --warm: #1557ff;
  --page: #fff5f3;
}

body[data-theme="blue"] {
  --primary: #1557ff;
  --accent: #73f2c0;
  --warm: #ffca3a;
  --page: #f1f6ff;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 25, 30, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 25, 30, 0.035) 1px, transparent 1px),
    var(--page);
  background-size: 28px 28px;
}

.auth-pending > :not(.auth-gate) {
  display: none !important;
}

.auth-gate {
  width: min(100% - 28px, 390px);
  margin: 0 auto;
  padding: clamp(72px, 14vh, 140px) 0 48px;
}

.auth-panel {
  padding: 30px 25px 26px;
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 7px 7px 0 var(--ink);
  text-align: center;
}

.auth-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border: 2px solid var(--ink);
  background: var(--accent);
  font-family: "Segoe UI Emoji", sans-serif;
  font-size: 31px;
}

.auth-kicker {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.auth-panel h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.auth-copy {
  margin: 9px 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.auth-panel input {
  width: 100%;
  height: 54px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 24px;
  font-weight: 850;
  letter-spacing: 0.18em;
  text-align: center;
}

.auth-panel input::placeholder {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
}

.auth-error {
  min-height: 21px;
  margin: 7px 0;
  color: #bd2a1c;
  font-size: 13px;
}

.auth-panel button {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--ink);
  background: var(--primary);
  color: white;
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--ink);
}

.auth-note {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.auth-shake {
  animation: auth-shake 0.35s ease;
}

@keyframes auth-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(-7px);
  }
  70% {
    transform: translateX(7px);
  }
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}

.app-header {
  position: relative;
  width: min(940px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 120px 27px;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.15;
  letter-spacing: 0;
  font-weight: 950;
}

.header-tools {
  position: absolute;
  top: 41px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 13px;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-size: 21px;
}

.theme-switcher {
  display: flex;
  gap: 7px;
}

.theme-swatch {
  width: 21px;
  height: 21px;
  padding: 0;
  border: 1px solid var(--ink);
}

.theme-swatch[aria-pressed="true"] {
  border-width: 3px;
  transform: translateY(-2px);
}

.theme-lime {
  background: #dfff00;
}

.theme-coral {
  background: #ff6b4a;
}

.theme-blue {
  background: #1557ff;
}

main {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding-bottom: 60px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.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;
}

.legal-note {
  max-width: 900px;
  margin: 22px auto 0;
  padding: 15px 17px;
  border-left: 5px solid var(--accent);
  background: var(--paper);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.help-popover {
  position: fixed;
  z-index: 100;
  max-width: 280px;
  padding: 10px 12px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  font-size: 13px;
  line-height: 1.55;
  box-shadow: 4px 4px 0 var(--accent);
}

dialog {
  width: min(620px, calc(100% - 28px));
  max-height: min(720px, calc(100vh - 36px));
  padding: 0;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
}

dialog::backdrop {
  background: rgba(17, 20, 26, 0.5);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-size: 22px;
}

#history-list {
  max-height: 500px;
  overflow: auto;
  padding: 10px 20px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

.history-actions button,
.danger-button {
  min-height: 34px;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.danger-button {
  margin: 14px 20px 20px;
  padding: 8px 13px;
  color: #b41f12;
}

@media (max-width: 700px) {
  .app-header {
    padding: 78px 0 24px;
  }

  .header-tools {
    top: 25px;
    right: 50%;
    transform: translateX(50%);
  }

  main {
    width: calc(100vw - 18px);
    max-width: 980px;
  }
}

@media (max-width: 500px) {
  .app-header h1 {
    font-size: 28px;
    line-height: 1.22;
  }
}

@media (max-width: 360px) {
  .app-header h1 {
    font-size: 25px;
  }
}
