/* Prorate. Calm paperwork: soft paper background, an indigo you can trust
   for the numbers that matter, a gold key in the corner. Big inputs, one
   clear total, readable on a phone while you're standing in the letting
   office. */

:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #eef0f9;
  --ink: #232539;
  --ink-2: #5d6076;
  --line: #e0e2f0;
  --accent: #4a5bd4;
  --accent-ink: #ffffff;
  --accent-soft: #e4e7fb;
  --good: #1f8a5b;
  --good-soft: #d9f2e5;
  --warn: #b5531c;
  --warn-soft: #fbe6d6;
  --shadow: 0 12px 28px -16px rgba(35, 37, 57, 0.4), 0 1px 0 rgba(35, 37, 57, 0.04);
  --radius: 20px;
  --radius-s: 12px;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Variable Display", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161f;
    --surface: #1e2030;
    --surface-2: #262940;
    --ink: #e9eaf4;
    --ink-2: #a7aac4;
    --line: #353854;
    --accent: #99a6f5;
    --accent-ink: #15161f;
    --accent-soft: #2b2f4c;
    --good: #5fd39c;
    --good-soft: #1e3a30;
    --warn: #f0a675;
    --warn-soft: #3a2a1c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  padding: 0 16px 150px;
}

.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top, main, .foot { max-width: 720px; margin: 0 auto; }
.top { padding: 32px 0 12px; }
.top h1 { font: 800 clamp(2rem, 7vw, 2.8rem)/1.05 var(--round); margin: 0; letter-spacing: -0.02em; color: var(--accent); }
.lede { margin: 8px 0 0; color: var(--ink-2); font-size: 1.05rem; max-width: 36rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 16px 0;
}
.card h2 { font: 700 1.2rem/1.2 var(--round); margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.card h2 small { font-weight: 500; color: var(--ink-2); font-size: 0.85rem; }
.num {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 0.95rem;
}
.hint { color: var(--ink-2); margin: -4px 0 14px; font-size: 0.95rem; }

.toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 16px; gap: 2px; }
.seg { font: 700 0.95rem var(--round); border: 0; background: transparent; color: var(--ink-2); padding: 9px 18px; border-radius: 999px; cursor: pointer; min-height: 42px; }
.seg.on { background: var(--accent); color: var(--accent-ink); }

.row { display: flex; flex-wrap: wrap; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; min-width: 0; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }

.money { position: relative; display: flex; align-items: center; }
.money i { position: absolute; left: 12px; font-style: normal; color: var(--ink-2); font-weight: 600; }
.money input { padding-left: 26px; }

input, select {
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  min-height: 46px;
  width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
input[aria-invalid="true"] { border-color: var(--warn); }

.check { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; min-height: 32px; cursor: pointer; font-size: 0.95rem; }
.check input { width: 22px; height: 22px; min-height: 0; flex: 0 0 auto; accent-color: var(--accent); }

.sub { color: var(--ink-2); margin: -4px 0 14px; }
.sub:empty { display: none; }

/* Each method, as a row with its daily rate and its amount. */
.method {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.method:first-child { border-top: 0; padding-top: 0; }
.method .m-main { flex: 1 1 auto; min-width: 0; }
.method h3 { margin: 0; font: 700 1.02rem var(--round); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.method .m-note { margin: 3px 0 0; color: var(--ink-2); font-size: 0.86rem; }
.method .m-daily { color: var(--ink-2); font-size: 0.86rem; }
.method .m-amount { font: 800 1.3rem var(--round); flex: 0 0 auto; text-align: right; white-space: nowrap; }
.method.pick { background: var(--accent-soft); margin: 0 -12px; padding: 14px 12px; border-radius: var(--radius-s); border-top: 0; }
.method.pick + .method { border-top: 0; }
.method.pick .m-amount { color: var(--accent); }

.tag { font: 700 0.68rem/1 var(--round); text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 7px; border-radius: 6px; }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.pick { background: var(--accent); color: var(--accent-ink); }

.spread { margin: 14px 0 0; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-s); font-size: 0.95rem; }
.spread:empty { display: none; }
.spread b { color: var(--accent); }

.cheque { margin-top: 18px; border: 2px solid var(--accent); border-radius: var(--radius-s); padding: 14px 16px; background: var(--surface); }
.cheque[hidden] { display: none; }
.cheque h3 { margin: 0 0 10px; font: 700 1.05rem var(--round); }
.cheque .line { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; color: var(--ink-2); }
.cheque .line.total { border-top: 1.5px solid var(--line); margin-top: 6px; padding-top: 10px; color: var(--ink); font: 800 1.25rem var(--round); }
.cheque .line.total span:last-child { color: var(--accent); }

.traps { margin-top: 18px; }
.traps[hidden] { display: none; }
.traps h3 { margin: 0 0 8px; font: 700 1.02rem var(--round); }
.traps ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.traps li { margin: 6px 0; }
.traps b { color: var(--ink); }

.method-pick { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.method-pick summary { cursor: pointer; font-weight: 700; color: var(--accent); min-height: 32px; }
.method-pick .field { margin-top: 10px; }

.btn {
  font: 700 1rem var(--round);
  border: 0; border-radius: 999px;
  padding: 12px 20px; min-height: 46px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn:active { transform: translateY(1px); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.status { min-height: 1.5em; color: var(--good); font-weight: 600; margin: 8px 0 0; }
.fine { color: var(--ink-2); font-size: 0.82rem; margin: 10px 0 0; }

.foot { color: var(--ink-2); font-size: 0.9rem; padding: 12px 0; }
.foot a { color: var(--accent); }

/* Kee, the house key. The bow is gold whatever the page theme. */
.kee-dock { position: fixed; right: 16px; bottom: 16px; z-index: 6; display: flex; align-items: flex-end; gap: 6px; transition: right .3s ease; }
.kee { width: 88px; height: 88px; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 24px; }
.kee svg { width: 100%; height: 100%; overflow: visible; }
.kee .k-bow { fill: #ecb63f; stroke: #8a6a1e; stroke-width: 3.5; }
.kee .k-bow-in { fill: none; stroke: #c4902a; stroke-width: 2.5; opacity: .6; }
.kee .k-shaft, .kee .k-tooth { fill: #ecb63f; stroke: #8a6a1e; stroke-width: 3; }
.kee .k-white { fill: #fff; stroke: #263330; stroke-width: 2; }
.kee .k-pupil { fill: #263330; transition: transform .08s linear; }
.kee .k-closed { fill: none; stroke: #263330; stroke-width: 3; stroke-linecap: round; display: none; }
.kee .k-cheek { fill: #e8705a; opacity: .55; }
.kee .k-mouth { fill: none; stroke: #263330; stroke-width: 3; stroke-linecap: round; display: none; }
.kee .k-mouth.wow { fill: #263330; stroke: none; }
.kee[data-mood="happy"] .k-mouth.happy,
.kee[data-mood="party"] .k-mouth.happy,
.kee[data-mood="worried"] .k-mouth.worried,
.kee[data-mood="wow"] .k-mouth.wow,
.kee[data-mood="sleepy"] .k-mouth.sleepy { display: block; }
.kee[data-mood="sleepy"] .k-white, .kee[data-mood="sleepy"] .k-pupil { display: none; }
.kee[data-mood="sleepy"] .k-closed { display: block; }
.kee.blink .k-white, .kee.blink .k-pupil { transform: scaleY(0.1); transform-box: fill-box; transform-origin: center; }
.kee .k-body { transform-origin: 60px 60px; animation: bob 3.4s ease-in-out infinite; }
.kee.hop .k-body { animation: hop .5s ease; }
.kee.jingle .k-body { animation: jingle .8s ease; }
.kee[data-mood="party"] .k-body { animation: spin .7s ease; }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-2deg); } }
@keyframes hop { 40% { transform: translateY(-14px) rotate(-6deg); } 70% { transform: translateY(0) rotate(3deg); } }
@keyframes jingle { 15% { transform: rotate(-16deg); } 35% { transform: rotate(12deg); } 55% { transform: rotate(-8deg); } 75% { transform: rotate(5deg); } }
@keyframes spin { 60% { transform: rotate(360deg) scale(1.05); } 100% { transform: rotate(360deg); } }

.bubble {
  max-width: min(64vw, 280px); background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  box-shadow: var(--shadow); border-radius: 16px 16px 4px 16px; padding: 10px 12px; font-size: 0.92rem; margin-bottom: 56px;
}
.bubble:empty { display: none; }
.bubble.pop { animation: pop .25s ease; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.kee-hide {
  position: absolute; right: -6px; top: -6px; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); cursor: pointer; font-size: 1rem; line-height: 1;
}
.kee-dock.tucked { right: -56px; opacity: .8; }
.kee-dock.tucked .kee-hide, .kee-dock.tucked .bubble { display: none; }
.spark { position: fixed; pointer-events: none; z-index: 7; color: #ecb63f; font-size: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  body { background: #fff; color: #000; padding: 0; }
  #step-move, #step-first, .method-pick, .result .actions, .kee-dock, .foot, .skip, .status { display: none !important; }
  .card { box-shadow: none; border: 0; }
}

@media (max-width: 480px) {
  .kee { width: 72px; height: 72px; }
  .card { padding: 16px; }
  .field { flex-basis: 100%; }
  .method .m-amount { font-size: 1.15rem; }
}
