/* Visual polish loaded after app.css. Unlayered so it wins over the layered base; colours keep their existing meanings. */
:root{--polish-shadow:0 1px 2px rgb(20 24 36 / .04),0 6px 20px rgb(20 24 36 / .05);--polish-card:20px;--polish-accent:#3d6a8f}
:root[data-theme=dark]{--polish-shadow:0 0 0 1px var(--line);--polish-accent:#8cb2e1}

@media (max-width:740px){
  body{background:var(--bg);-webkit-tap-highlight-color:transparent}

  /* Header: lighter, shorter, logo no longer dominates. */
  .site-header{height:54px;border-bottom:0;box-shadow:0 1px 0 color-mix(in srgb,var(--line) 70%,transparent)}
  .brand-mark,.brand-logo{width:34px;height:34px}
  .brand-logo{border-radius:10px}
  .account-link{border:0;border-radius:999px;padding:6px 14px;font-weight:600}
  .workspace{padding-top:14px}

  /* Cards: soft elevation instead of hard outlines. */
  .countdown-panel,.latest-panel,.draw-shortcuts,.history-panel{border:0;border-radius:var(--polish-card);box-shadow:var(--polish-shadow)}
  .draw-layout{gap:12px}
  .workspace .panel{box-shadow:var(--polish-shadow)}
  .workspace .panel:not([class*=active]):not([class*=selected]){border-color:color-mix(in srgb,var(--line) 45%,transparent)}
  .page-heading{margin-bottom:14px}
  .page-heading h1{font-size:24px;font-weight:700;letter-spacing:-.4px}
  .tool-tabs{border:0;border-radius:14px;box-shadow:var(--polish-shadow)}

  /* Countdown */
  .countdown-panel{padding:16px 18px 14px}
  .timer-value strong{font-weight:700;letter-spacing:-1px;font-variant-numeric:tabular-nums}
  .countdown-track{height:6px;border-radius:99px;background:color-mix(in srgb,var(--ink) 8%,transparent)}
  .countdown-track i{border-radius:99px;background:linear-gradient(90deg,var(--polish-accent),color-mix(in srgb,var(--polish-accent) 60%,#8fd3c7))}

  /* Latest draw: issue + time on one line, controls as an even row beneath. */
  .draw-layout:not(.draw-style-traditional) .latest-panel{padding:16px 16px 14px}
  .draw-layout:not(.draw-style-traditional) .latest-top{grid-template-columns:1fr auto;align-items:baseline;gap:12px 10px}
  .draw-layout:not(.draw-style-traditional) .latest-top>div:first-child{display:contents}
  .draw-layout:not(.draw-style-traditional) .latest-top strong{grid-area:1/1;font-size:17px;font-weight:700;letter-spacing:-.2px}
  .draw-layout:not(.draw-style-traditional) .latest-top strong small{font-weight:500;color:var(--muted);font-size:12px}
  .draw-layout:not(.draw-style-traditional) .latest-top time{grid-area:1/2;width:auto;margin:0;justify-self:end;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
  .draw-layout:not(.draw-style-traditional) .latest-controls{grid-area:2/1/3/3;width:100%;margin:0;display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px;padding:4px;border-radius:14px;background:var(--surface-soft)}
  .draw-layout:not(.draw-style-traditional) .latest-controls>button{height:34px;min-height:34px;border:0;border-radius:10px;background:transparent;color:var(--ink);box-shadow:none;font-size:13px;font-weight:600;justify-content:center}
  .draw-layout:not(.draw-style-traditional) .latest-controls>button[aria-pressed=true]{background:var(--surface);box-shadow:0 1px 3px rgb(0 0 0 / .1)}
  .draw-layout:not(.draw-style-traditional) .latest-controls .draw-settings-button{background:var(--ink);color:var(--surface);box-shadow:0 1px 3px rgb(0 0 0 / .18)}

  /* Balls: slightly rounder, with gentle depth. */
  .draw-layout:not(.draw-style-traditional) .ball-equation{margin-top:4px}
  .draw-layout:not(.draw-style-traditional) :is(.ball,.sum-ball){border-radius:18px;box-shadow:inset 0 1px 0 rgb(255 255 255 / .22),inset 0 -2px 0 rgb(0 0 0 / .12),0 4px 10px -4px rgb(0 0 0 / .35)}
  .draw-layout:not(.draw-style-traditional) .ball-equation i{font-size:16px;font-style:normal;opacity:.7}

  /* Result tags: same shape for all four, a touch lighter. */
  .draw-layout:not(.draw-style-traditional) .result-primary{gap:8px}
  .draw-layout:not(.draw-style-traditional) .result-primary .result-tag{height:42px;min-height:42px;border-radius:14px;font-size:17px;outline:0;box-shadow:inset 0 -2px 0 rgb(0 0 0 / .1)}
  .draw-layout:not(.draw-style-traditional) .result-primary .result-tag:is(.pattern-pair,.pattern-run,.pattern-mixed,.pattern-triple){font-size:15px;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--category-fg) 22%,transparent)}
  .draw-layout:not(.draw-style-traditional) .draw-details{border-radius:14px;padding:10px 6px}
  .draw-layout:not(.draw-style-traditional) .draw-details b{font-size:13px}
  .scratch-hint{text-align:center;font-size:11px;opacity:.8}

  /* Shortcuts: tappable chips. */
  .draw-shortcuts{display:grid;grid-template-columns:repeat(6,1fr);gap:4px;padding:8px}
  .draw-shortcuts>:is(a,button){height:44px;min-height:44px;min-width:0;padding:0;flex-direction:row;justify-content:center;border-radius:12px;background:var(--surface-soft);color:var(--ink);font-size:14px;font-weight:600;white-space:nowrap;border:0}
  :root:is([data-theme=buddha],[data-theme=caishen]) .draw-shortcuts>:is(a,button){color:var(--ink)}
  .draw-shortcuts>:is(a,button):active{transform:scale(.97)}

  /* History list: larger, easier-to-read rows. */
  .history-panel{padding:18px 12px 14px}
  .history-panel .section-title h2{font-size:19px;font-weight:700}
  .history-panel .section-title span{font-size:12px;color:var(--muted)}
  .history-panel .search-field{border:0;background:var(--surface-soft)}
  .history-panel .search-field input{background:transparent;border:0}
  .history-panel #refresh{border:0;background:var(--surface-soft);font-weight:600}
  .history-compact{border-radius:14px;overflow:hidden}
  .history-compact thead th{background:transparent;font-size:11px;letter-spacing:.3px;border-bottom:1px solid var(--line)}
  .history-compact tbody :is(th,td){padding-top:10px;padding-bottom:10px;border-bottom:1px solid color-mix(in srgb,var(--line) 65%,transparent)}
  .history-compact tbody td time{color:var(--muted);font-size:11px}
  .history-compact .tag{min-width:22px;height:22px;border-radius:7px;font-size:11px}
  .history-compact .tag:is(.pattern-pair,.pattern-run,.pattern-mixed,.pattern-triple){padding:0 6px}
  .history-compact tbody th{background:var(--surface);color:var(--ink)}

  /* Algorithm hall filters: one tidy control block. */
  .hall-filters{gap:8px;padding:10px;border:0;border-radius:18px;background:var(--surface);box-shadow:var(--polish-shadow)}
  .hall-categories{display:flex;flex-wrap:nowrap;gap:6px;overflow-x:auto;scrollbar-width:none}
  .hall-categories::-webkit-scrollbar{display:none}
  .hall-categories>button{flex:1 0 auto;height:34px;padding:0 12px;border-radius:99px;border:0;background:var(--surface-soft);font-size:13px;font-weight:600}
  .hall-categories>button[aria-pressed=true]{background:var(--polish-accent);color:#fff}
  .hall-sort-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto auto;gap:6px;align-items:center}
  .hall-sort-row select,.hall-search-row input{height:38px;min-height:38px;padding:0 10px;border:0;border-radius:12px;background:var(--surface-soft);width:100%}
  .hall-sort-row>button,.hall-search-row>button{height:38px;min-height:38px;padding:0 12px;white-space:nowrap;border:0;border-radius:12px;background:var(--surface-soft);font-size:13px;font-weight:600;color:var(--ink)}
  .hall-upload{white-space:nowrap;font-size:13px;font-weight:600;padding:0 4px}
  .hall-search-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:6px}
  .hall-search-row>button[aria-pressed=true]{background:color-mix(in srgb,var(--polish-accent) 14%,var(--surface));color:var(--polish-accent)}

  /* Bottom bar: clear active state and safe-area padding. */
  .mobile-nav{border-top:0;box-shadow:0 -1px 0 color-mix(in srgb,var(--line) 70%,transparent);padding-bottom:max(6px,env(safe-area-inset-bottom))}
  .mobile-nav>:is(a,button){color:var(--muted);gap:2px}
  .mobile-nav>:is(a,button) svg{width:26px;height:26px;padding:2px 0;border-radius:99px;transition:background .2s}
  .mobile-nav>.active{color:var(--ink);font-weight:650}
  .mobile-nav>.active svg{width:44px;background:color-mix(in srgb,var(--polish-accent) 14%,transparent);color:var(--polish-accent)}
}
/* History list at every width: quieter issue numbers, slightly larger results. */
.history-compact tbody th{font-size:9.35px;font-weight:500}
.history-compact .compact-equation{font-size:17.48px;font-weight:600}
.history-compact .compact-equation b{font-size:inherit}

@media (max-width:740px) and (prefers-reduced-motion:reduce){.draw-shortcuts>:is(a,button):active{transform:none}}

/* Undrawn next issue at the top of the history list in scratch mode. */
.upcoming-note{color:var(--muted);font-size:12px;letter-spacing:.5px}
.history-upcoming :is(th,td){color:var(--muted)}
.history-card.history-upcoming{display:flex;justify-content:space-between;align-items:center}
