:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #18140f;
  background: #f7edda;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #18140f;
  --paper: #fffaf0;
  --cream: #f7edda;
  --night: #15253d;
  --night-soft: #263b59;
  --blue: #b9d9ee;
  --yellow: #f4d364;
  --red: #e75744;
  --green: #a9d6ad;
  --muted: #6c5f52;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--cream); }
body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 88% 3%, rgba(185, 217, 238, 0.76), transparent 330px),
    linear-gradient(90deg, rgba(24, 20, 15, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 20, 15, 0.04) 1px, transparent 1px),
    var(--cream);
  background-size: auto, 34px 34px, 34px 34px, auto;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
a { color: inherit; }
[hidden] { display: none !important; }

.app { width: min(1160px, calc(100% - 32px)); margin: 0 auto; padding: 18px 0 34px; }
.topbar, .footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand, .year-pill { border: 2px solid var(--ink); background: var(--paper); font-weight: 950; }
.brand { display: inline-flex; align-items: center; gap: 8px; border-radius: 8px; box-shadow: 4px 4px 0 var(--ink); padding: 10px 13px; text-decoration: none; }
.brand span { color: var(--red); font-size: 19px; }
.year-pill { border-radius: 999px; padding: 8px 12px; color: #3d342c; font-size: 13px; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 30px; padding: 44px 0 26px; }
.eyebrow { margin: 0 0 12px; color: var(--red); font-size: 13px; font-weight: 1000; letter-spacing: 0.14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 16px; font-size: clamp(43px, 6.3vw, 74px); line-height: 0.98; letter-spacing: -0.045em; }
h1 span { color: var(--red); }
.lead { max-width: 770px; margin: 0; color: #4d4238; font-size: 18px; font-weight: 720; line-height: 1.7; }
.sky-note { display: grid; min-width: 210px; justify-items: center; border: 3px solid var(--ink); border-radius: 18px; background: var(--night); box-shadow: 7px 7px 0 var(--ink); padding: 17px 20px; color: white; text-align: center; transform: rotate(2deg); }
.sky-note span, .sky-note small { font-weight: 900; }
.sky-note strong { margin: 4px 0; color: var(--yellow); font-size: 27px; }
.sky-note small { color: #d6e5ef; font-size: 12px; }

.workspace { display: grid; grid-template-columns: minmax(0, 0.93fr) minmax(420px, 1.07fr); align-items: start; gap: 20px; }
.panel { min-width: 0; border: 3px solid var(--ink); border-radius: 14px; background: var(--paper); box-shadow: 8px 8px 0 var(--ink); padding: 22px; }
.panel-title { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.panel-title h2 { margin-bottom: 4px; font-size: 25px; line-height: 1.08; }
.panel-title p { margin: 0; color: var(--muted); font-size: 14px; font-weight: 720; line-height: 1.55; }
.step-number { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border: 2px solid var(--ink); border-radius: 8px; background: var(--blue); box-shadow: 3px 3px 0 var(--ink); font-weight: 1000; }
.step-number.red { background: #ffc7be; color: #9f2619; }
.step-number.yellow { background: var(--yellow); }

.field { display: grid; min-width: 0; gap: 7px; font-size: 13px; font-weight: 900; }
.field > span:first-child, legend { font-weight: 950; }
.field small { color: var(--muted); font-weight: 700; line-height: 1.45; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
input[type="date"], input[type="number"], select { width: 100%; min-height: 48px; border: 2px solid var(--ink); border-radius: 8px; background: #fffefa; padding: 9px 11px; color: var(--ink); font-weight: 850; }
.full-field select { font-size: 16px; }
.custom-location { border: 2px dashed var(--ink); border-radius: 10px; background: #f3f7f8; padding: 12px; }
.range-field { margin-top: 20px; border: 2px solid var(--ink); border-radius: 10px; background: #f6fbff; padding: 14px; }
.range-field > span:first-child { display: flex; justify-content: space-between; }
.range-field output { color: var(--red); font-size: 18px; }
input[type="range"] { width: 100%; accent-color: var(--red); }
.range-ends { display: flex; justify-content: space-between; }

.bortle-field { min-width: 0; margin: 18px 0 0; border: 2px solid var(--ink); border-radius: 10px; padding: 14px; }
legend { padding: 0 7px; }
.bortle-choices { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
.bortle-choices label { cursor: pointer; }
.bortle-choices input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.bortle-choices span { display: grid; min-height: 39px; place-items: center; border: 2px solid var(--ink); border-radius: 7px; background: white; font-weight: 1000; }
.bortle-choices input:checked + span { background: var(--night); color: white; box-shadow: 2px 2px 0 var(--red); transform: translate(-1px, -1px); }
.bortle-field p { margin: 10px 0 0; color: var(--muted); font-size: 13px; font-weight: 750; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-actions button { flex: 1; min-height: 48px; border: 2px solid var(--ink); border-radius: 8px; background: white; box-shadow: 3px 3px 0 var(--ink); font-weight: 950; }
.form-actions .primary-button { background: var(--yellow); }
.form-error { margin: 14px 0 0; border-left: 4px solid var(--red); padding: 8px 10px; color: #9f2619; font-weight: 850; }

.result-panel { position: sticky; top: 16px; background: var(--night); color: white; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.result-kicker { margin-bottom: 6px; color: #c5d9e8; font-size: 13px; font-weight: 950; letter-spacing: 0.05em; }
.result-head h2 { margin: 0; color: var(--green); font-size: clamp(38px, 5vw, 56px); line-height: 1; }
.result-head h2[data-tone="yellow"] { color: var(--yellow); }
.result-head h2[data-tone="red"] { color: #ff9181; }
.score-ring { display: grid; width: 88px; height: 88px; flex: 0 0 auto; place-content: center; border: 3px solid var(--green); border-radius: 50%; text-align: center; }
.score-ring[data-tone="yellow"] { border-color: var(--yellow); }
.score-ring[data-tone="red"] { border-color: #ff9181; }
.score-ring strong { font-size: 32px; line-height: 0.9; }
.score-ring span { color: #bdccda; font-size: 12px; }

.window-card { display: grid; gap: 4px; margin-top: 20px; border: 2px solid white; border-radius: 12px; background: #213754; padding: 16px; }
.window-card span { color: var(--yellow); font-size: 12px; font-weight: 950; }
.window-card strong { font-size: clamp(31px, 4.6vw, 50px); letter-spacing: -0.04em; }
.window-card small { color: #d5e3ee; font-weight: 750; }
.fact-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.fact-grid article { min-width: 0; border: 2px solid rgba(255,255,255,0.85); border-radius: 9px; background: rgba(255,255,255,0.07); padding: 11px; }
.fact-grid span, .fact-grid small { display: block; color: #c5d9e8; font-size: 11px; font-weight: 800; }
.fact-grid strong { display: block; margin: 5px 0 3px; overflow-wrap: anywhere; font-size: 18px; }
.score-breakdown { margin-top: 18px; }
.score-breakdown h3 { margin-bottom: 10px; font-size: 16px; }
.score-row { display: grid; grid-template-columns: 108px minmax(0, 1fr) 42px; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; font-weight: 850; }
.score-row > div { height: 8px; overflow: hidden; border: 1px solid white; border-radius: 999px; background: #0f1d31; }
.score-row i { display: block; height: 100%; background: var(--yellow); }
.score-row strong { text-align: right; }
.advice-box { margin-top: 18px; border-left: 5px solid var(--yellow); background: #fff8e8; padding: 13px 15px; color: var(--ink); }
.advice-box strong { font-size: 14px; }
.advice-box ul { margin: 7px 0 0; padding-left: 18px; }
.advice-box li { margin-top: 4px; font-size: 13px; font-weight: 740; line-height: 1.45; }

.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 24px; }
.compact-panel { box-shadow: 6px 6px 0 var(--ink); }
.compact-title { margin: 0; }
.source-note { margin-top: 24px; border: 2px dashed var(--ink); border-radius: 12px; background: rgba(255,250,240,0.78); padding: 18px; }
.source-note > strong { font-size: 17px; }
.source-note p { margin: 7px 0 10px; color: var(--muted); font-size: 13px; font-weight: 700; line-height: 1.65; }
.source-note div { display: flex; flex-wrap: wrap; gap: 12px; }
.source-note a { color: #234f76; font-size: 13px; font-weight: 900; }
.footer { margin-top: 26px; border-top: 2px solid var(--ink); padding-top: 18px; color: var(--muted); font-size: 13px; font-weight: 800; }
.footer nav { display: flex; gap: 14px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .result-panel { position: static; }
}

@media (max-width: 640px) {
  .app { width: min(100% - 20px, 1160px); padding-top: 10px; }
  .year-pill { display: none; }
  .hero { grid-template-columns: 1fr; gap: 18px; padding: 34px 0 22px; }
  .hero h1 { font-size: 45px; }
  .lead { font-size: 16px; }
  .sky-note { width: min(260px, 88%); justify-self: end; }
  .panel { border-width: 2px; box-shadow: 5px 5px 0 var(--ink); padding: 16px; }
  .field-grid, .info-grid { grid-template-columns: 1fr; }
  .bortle-choices { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .fact-grid { grid-template-columns: 1fr; }
  .fact-grid article { display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 2px 8px; }
  .fact-grid small { grid-column: 2; }
  .result-head h2 { font-size: 38px; }
  .score-ring { width: 76px; height: 76px; }
  .window-card strong { font-size: 34px; }
  .score-row { grid-template-columns: 92px minmax(0, 1fr) 40px; }
  .form-actions { flex-direction: column; }
  .footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 360px) {
  .hero h1 { font-size: 40px; }
  .result-head { align-items: flex-start; }
  .score-ring { width: 68px; height: 68px; }
  .score-ring strong { font-size: 27px; }
}
