/* 键速 — cobalt typing bench. Shared shell: base.css */
:root {
  --accent: #2456d6;
  --accent-dark: #16327f;
  --accent-soft: #dce5ff;
  --ink: #151a2b;
  --muted: #5f6578;
  --line: #1a2340;
  --soft-line: #ccd2e1;
  --paper: #e9ecf6;
  --paper-deep: #dce1ef;
  --card: #fcfaf4;
  --card-soft: #f5f1e7;
  --green: #18725c;
  --type-navy: #111b3a;
  --type-navy-deep: #080f24;
  --type-cyan: #7ee0d3;
  --type-cyan-soft: #c8f5ef;
  --type-cream: #f7f2e6;
  --type-red: #c54220;
  --type-line: #c8d0e3;
}

body {
  background-color: #eef0f8;
  background-image:
    radial-gradient(circle at 94% -8%, rgba(126, 224, 211, .30), transparent 31rem),
    radial-gradient(circle at 2% 38%, rgba(36, 86, 214, .08), transparent 28rem),
    linear-gradient(rgba(17, 27, 58, .042) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 27, 58, .042) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px, 28px 28px;
}

::selection { color: var(--type-cream); background: var(--accent-dark); }
.site-header { border-bottom-color: rgba(26, 35, 64, .16); }
.brand-mark {
  color: var(--type-cream);
  background: var(--accent);
  transform: rotate(-2deg);
}
.brand-copy small { color: #636b83; }
.top-nav a::after { background: var(--type-cyan); }
.site-footer { background: var(--type-navy-deep); }
.footer-brand p { color: #a8b0c8; }

/* Hero */
.typing-hero {
  grid-template-columns: minmax(0, 1.18fr) minmax(330px, .82fr);
  gap: clamp(38px, 7vw, 88px);
  padding-block: clamp(50px, 7vw, 94px) 70px;
}

.typing-hero h1 {
  max-width: 760px;
  font-size: clamp(55px, 7.8vw, 98px);
  line-height: .96;
  letter-spacing: -.075em;
}

.typing-hero h1 em {
  color: var(--accent-dark);
  display: inline-block;
  transform: rotate(-1.2deg);
}

.typing-hero h1 em::after {
  left: -.03em;
  right: -.03em;
  bottom: .05em;
  height: .23em;
  background: var(--type-cyan);
  border-radius: 2px;
  opacity: .8;
}

.typing-hero .hero-lead { max-width: 640px; color: #4b5166; }
.typing-hero .hero-facts span {
  color: var(--accent-dark);
  background: rgba(252, 250, 244, .72);
  border-color: var(--type-line);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 30px;
}

.hero-actions .button { min-width: 192px; }

.hero-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.type-preview {
  isolation: isolate;
  overflow: hidden;
  width: min(100%, 470px);
  justify-self: end;
  padding: 26px;
  color: #edf1ff;
  background:
    linear-gradient(145deg, rgba(126, 224, 211, .12), transparent 38%),
    linear-gradient(160deg, #192a5b, var(--type-navy-deep));
  border: 2px solid var(--ink);
  border-radius: 26px;
  box-shadow: 12px 12px 0 var(--type-cyan);
  transform: rotate(1.2deg);
}

.type-preview::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 8px;
  border: 1px solid rgba(126, 224, 211, .16);
  border-radius: 19px;
  pointer-events: none;
}

.type-preview::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: -55px;
  top: -60px;
  width: 190px;
  height: 190px;
  background: radial-gradient(circle, rgba(126, 224, 211, .18), transparent 68%);
  pointer-events: none;
}

.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 15px;
  color: #9eadd5;
  border-bottom: 1px dashed rgba(126, 224, 211, .26);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .13em;
}

.preview-timer { color: var(--type-cyan); font-size: 12px; letter-spacing: .05em; }

.preview-text {
  margin: 23px 0 20px;
  font-family: var(--font-display);
  font-size: clamp(23px, 3.1vw, 31px);
  line-height: 1.82;
  letter-spacing: .025em;
  color: #7c8ab4;
}

.preview-text span { border-radius: 3px; }
.preview-text .is-done { color: #f4f1e7; }
.preview-text .is-bad {
  color: #fff;
  background: var(--type-red);
  text-decoration: underline wavy rgba(255, 255, 255, .65);
}
.preview-text .is-now {
  color: var(--type-navy-deep);
  background: var(--type-cyan);
  box-shadow: 0 0 0 3px rgba(126, 224, 211, .16);
}

.preview-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.preview-metrics div {
  padding: 14px 15px;
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(126, 224, 211, .18);
  border-radius: 11px;
}

.preview-metrics strong {
  display: block;
  color: var(--type-cyan);
  font-family: var(--font-mono);
  font-size: clamp(31px, 4vw, 40px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.06em;
}

.preview-metrics strong small { font-size: 16px; letter-spacing: 0; }
.preview-metrics span {
  display: block;
  margin-top: 5px;
  color: #9eadd5;
  font-size: 9px;
  letter-spacing: .08em;
}

.preview-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  color: #8493bb;
  font-size: 10px;
}

.preview-keys kbd {
  min-width: 30px;
  padding: 5px 7px;
  color: #d9e2ff;
  background: #0a122e;
  border: 1px solid #3a4879;
  border-bottom-width: 3px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
}

.preview-keys span { margin-left: auto; }

/* Typing workbench */
.typing-tool { scroll-margin-top: 26px; }
.typing-card {
  overflow: hidden;
  background: rgba(252, 250, 244, .98);
  border-radius: 20px;
}

.typing-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--accent), var(--type-cyan) 68%, transparent);
}

.typing-card .tool-heading { align-items: flex-start; }
.typing-card .tool-heading p:not(.section-index) { max-width: 560px; }

.status-pill {
  color: var(--muted);
  background: var(--paper);
  white-space: nowrap;
}

.status-pill.is-running {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.status-pill.is-ok {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.source-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

.source-bar .mode-tabs { margin: 0; }
.mode-tab .tiny-lock { margin-left: 4px; }
.mode-tab:disabled { opacity: .48; cursor: not-allowed; }
body.is-premium .mode-tab .tiny-lock { display: none; }

.new-text-btn { flex: 0 0 auto; white-space: nowrap; }
.new-text-btn:disabled,
.text-button:disabled {
  color: var(--muted);
  text-decoration: none;
  opacity: .5;
  cursor: not-allowed;
}

.duration-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--soft-line);
  border-radius: 12px;
}

.duration-label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .14em;
}

.duration-tabs { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  min-height: 36px;
  padding: 6px 12px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--soft-line);
  border-radius: 100px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}

.chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.chip.is-active {
  color: var(--card);
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--accent);
}

.timer-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  margin-left: auto;
  line-height: 1;
}

.timer-caption {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .14em;
}

.timer-display {
  color: var(--accent-dark);
  font-family: var(--font-mono);
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: -.055em;
  font-variant-numeric: tabular-nums;
}

.text-stage {
  margin-top: 18px;
  padding: 14px 18px 16px;
  background: #fffdf8;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}

.text-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  padding-bottom: 10px;
  color: var(--muted);
  border-bottom: 1px dashed var(--soft-line);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .05em;
}

.type-text {
  position: relative;
  max-height: clamp(210px, 33vh, 330px);
  padding: 15px 2px 8px;
  overflow-y: auto;
  color: #756c61;
  font-family: var(--font-sans);
  font-size: clamp(18px, 2.35vw, 24px);
  line-height: 1.95;
  letter-spacing: .012em;
  scrollbar-width: thin;
  scrollbar-color: var(--soft-line) transparent;
}

.type-text::-webkit-scrollbar { width: 8px; }
.type-text::-webkit-scrollbar-thumb { background: var(--soft-line); border-radius: 100px; }

.type-text .char {
  border-radius: 3px;
  transition: color .08s ease, background .08s ease, box-shadow .08s ease;
}

.type-text .char.is-space { white-space: pre; }
.type-text .char.is-pending { color: #756c61; }
.type-text .char.is-correct { color: var(--ink); }
.type-text .char.is-wrong {
  color: #fff;
  background: var(--type-red);
  text-decoration: underline wavy rgba(255, 255, 255, .66);
}

.type-text .char.is-current {
  color: var(--ink);
  background: var(--accent-soft);
  box-shadow: inset 0 -3px 0 var(--accent);
  animation: caret-blink 1.05s steps(2, end) infinite;
}

@keyframes caret-blink {
  0%, 48% { box-shadow: inset 0 -3px 0 var(--accent); }
  52%, 100% { box-shadow: inset 0 -3px 0 transparent; }
}

.type-progress {
  height: 6px;
  margin-top: 12px;
  overflow: hidden;
  background: var(--paper-deep);
  border-radius: 100px;
}

.type-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--type-cyan));
  border-radius: inherit;
  transition: width .18s ease;
}

.input-label { margin-top: 18px; }
.input-label > span:last-child {
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.typing-input {
  min-height: 92px;
  padding: 13px 15px;
  color: var(--ink);
  background: #fffdf8;
  border: 1.5px solid #8a91a8;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.7;
  caret-color: var(--accent);
}

.typing-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 86, 214, .14);
}

.typing-input:read-only { background: #f1efe9; }

.live-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 15px;
}

.live-grid .stat {
  min-width: 0;
  padding: 11px 13px;
  background: var(--paper);
  border: 1px solid var(--soft-line);
  border-radius: 10px;
}

.live-grid .stat strong {
  overflow: hidden;
  font-size: clamp(20px, 2.5vw, 27px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-grid .stat span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: .02em;
}

.typing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px 10px;
  margin-top: 16px;
}

.typing-actions .button { min-width: 128px; }
.typing-actions .mini-note { flex: 1 0 210px; margin: 0; }

#result {
  margin-top: 20px;
  padding: 20px 22px;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--accent);
  font-family: var(--font-display);
  font-size: clamp(25px, 4.2vw, 36px);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -.025em;
  white-space: pre-wrap;
}

#result:empty {
  color: var(--muted);
  background: var(--card-soft);
  border-style: dashed;
  box-shadow: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
}

#result:not(:empty) { animation: result-in .25s ease-out; }

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

.result-detail {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

/* Premium suite */
.premium-shell { margin-top: 52px; scroll-margin-top: 28px; }
.premium-shell .guide-heading h2 { color: var(--type-navy); }

.premium-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 22px;
  margin-top: 22px;
}

.premium-grid > .premium-card { height: 100%; }
.custom-card textarea { min-height: 154px; }
.custom-card .field-label { margin-bottom: 8px; }

.custom-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  margin-top: 12px;
}

.custom-count {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .02em;
}

#customMessage { min-height: 18px; }

.history-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 13px;
}

.history-stats div {
  min-width: 0;
  padding: 11px;
  background: var(--paper);
  border: 1px solid var(--soft-line);
  border-radius: 9px;
}

.history-stats strong {
  display: block;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 21px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-stats span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.3;
}

.chart-wrap {
  position: relative;
  padding: 10px;
  background: #f9f7f1;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
}

.history-chart {
  width: 100%;
  height: 196px;
}

.chart-empty {
  position: absolute;
  inset: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  color: var(--muted);
  background: rgba(249, 247, 241, .76);
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
}

.history-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 14px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 9.5px;
}

.history-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.is-zh { background: var(--accent); }
.legend-dot.is-en { background: var(--green); }
.legend-dot.is-custom { background: var(--ink); }
.history-legend .legend-unit { margin-left: auto; font-family: var(--font-mono); }

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.history-toolbar h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: -.01em;
}

.history-toolbar .text-button { min-height: 44px; font-size: 11px; }

.history-list {
  display: grid;
  gap: 6px;
  max-height: 228px;
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: var(--soft-line) transparent;
}

.history-list::-webkit-scrollbar { width: 7px; }
.history-list::-webkit-scrollbar-thumb { background: var(--soft-line); border-radius: 100px; }

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 9px 11px;
  background: var(--card);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
}

.history-row strong {
  grid-column: 1;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row span {
  grid-column: 1;
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row b {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.history-empty {
  padding: 20px 15px;
  color: var(--muted);
  background: var(--card-soft);
  border: 1px dashed #b7b1a2;
  border-radius: 9px;
  font-size: 11.5px;
  line-height: 1.7;
  text-align: center;
}

body.is-premium .premium-chip { background: var(--green); border-color: var(--green); }
body.is-premium .status-pill.is-running { background: var(--accent); }

/* Footer accents */
.footer-mark,
.footer-brand .brand-mark.small {
  color: var(--type-navy-deep);
  background: var(--type-cyan);
}

.footer-links a:hover,
#toolLinks a:hover { color: var(--type-cyan); }

/* Responsive */
@media (max-width: 980px) {
  .typing-hero { grid-template-columns: 1fr; }
  .type-preview {
    justify-self: start;
    width: min(100%, 470px);
    transform: rotate(.8deg);
    box-shadow: 9px 9px 0 var(--type-cyan);
  }
  .premium-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .typing-hero { gap: 34px; padding-top: 44px; padding-bottom: 52px; }
  .typing-hero h1 { font-size: clamp(47px, 15vw, 70px); }
  .type-preview { width: 100%; padding: 21px; border-radius: 21px; box-shadow: 7px 7px 0 var(--type-cyan); }
  .preview-text { font-size: clamp(21px, 5.6vw, 28px); line-height: 1.75; }
  .preview-metrics strong { font-size: 33px; }
  .preview-keys span { width: 100%; margin-left: 0; }

  .source-bar { align-items: stretch; }
  .source-bar .mode-tabs { width: 100%; }
  .source-bar .mode-tab { flex: 1 1 auto; }
  .new-text-btn { align-self: flex-end; }

  .duration-bar { align-items: center; }
  .timer-box { margin-left: 0; }
  .timer-display { font-size: 27px; }

  .type-text { max-height: 245px; font-size: 18px; line-height: 1.85; }
  .typing-input { min-height: 96px; font-size: 16px; }
  .live-grid { grid-template-columns: 1fr 1fr; }
  .typing-actions .mini-note { flex-basis: 100%; }
  .typing-actions .button { flex: 1 1 auto; }
  .history-chart { height: 178px; }
  .history-stats strong { font-size: 19px; }
}

@media (max-width: 420px) {
  .typing-hero { padding-top: 36px; }
  .typing-hero h1 { font-size: clamp(43px, 14.4vw, 58px); }
  .typing-card { padding: 17px; }
  .text-stage { padding: 12px 13px 14px; }
  .type-text { max-height: 230px; font-size: 17px; }
  .duration-tabs { width: 100%; }
  .chip { flex: 1 1 58px; padding-inline: 8px; }
  .timer-box { width: 100%; flex-direction: row; align-items: baseline; justify-content: space-between; }
  .input-label { display: block; }
  .input-label > span:last-child { display: block; margin-top: 2px; }
  .live-grid { gap: 6px; }
  .live-grid .stat { padding: 10px 11px; }
  .history-stats { grid-template-columns: 1fr 1fr; }
  .history-stats div:first-child { grid-column: 1 / -1; }
  .history-legend .legend-unit { width: 100%; margin-left: 0; }
  .custom-actions .button { width: 100%; }
  #result { padding: 17px; font-size: clamp(23px, 8vw, 30px); }
}

@media (prefers-reduced-motion: reduce) {
  .type-preview { transform: none; }
  .typing-hero h1 em { transform: none; }
}
