/* ==========================================================
   Utilo design system
   Material 3 Expressive inspired tokens, components and motion
   ========================================================== */

/* ---------- Tokens: light (default) ---------- */
:root {
  --primary: #4f4fd1;
  --on-primary: #ffffff;
  --primary-container: #e3e0ff;
  --on-primary-container: #15135e;

  --secondary-container: #e9dcff;
  --on-secondary-container: #260f4a;

  --tertiary-container: #ffd8e4;
  --on-tertiary-container: #3b0a1f;

  --surface: #fbf9ff;
  --surface-1: #f4f1fa;
  --surface-2: #ece8f4;
  --surface-3: #e4dfee;

  --on-surface: #1b1a20;
  --on-surface-variant: #4a4757;
  --outline: #7b7788;
  --outline-variant: #cdc8d9;

  --error: #ba1a1a;
  --error-container: #ffdad6;
  --on-error-container: #410002;

  --focus: #4f4fd1;

  --ease-spring: cubic-bezier(0.3, 1.2, 0.5, 1);
  --ease-std: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- Tokens: dark ---------- */
html[data-theme="dark"] {
  --primary: #c4c1ff;
  --on-primary: #2a2790;
  --primary-container: #3d3bb0;
  --on-primary-container: #e3e0ff;

  --secondary-container: #4a2f74;
  --on-secondary-container: #ecdcff;

  --tertiary-container: #6e2e47;
  --on-tertiary-container: #ffd8e4;

  --surface: #131217;
  --surface-1: #1b1a21;
  --surface-2: #24232c;
  --surface-3: #2e2d37;

  --on-surface: #e6e1ea;
  --on-surface-variant: #c9c4d3;
  --outline: #938f9c;
  --outline-variant: #48464f;

  --error: #ffb4ab;
  --error-container: #93000a;
  --on-error-container: #ffdad6;

  --focus: #c4c1ff;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-family: "Roboto Flex", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

/* Material Symbols icon font. Falls back to text if the font is not loaded. */
.ms {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.38; cursor: not-allowed; }
input, textarea { font: inherit; color: inherit; }

/* ---------- App bar ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px 16px;
  background: var(--surface);
}
.app-bar h1 {
  flex: 1;
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform 0.34s var(--ease-spring), background 0.2s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.98); }

/* ---------- Layout ---------- */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px 24px;
}

/* ---------- Hero (asymmetric corners on purpose) ---------- */
.hero {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: 40px 14px 40px 14px;
  padding: 24px 24px 28px;
  margin: 8px 0 16px;
}
.hero h2 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero p { margin: 0; opacity: 0.85; }

/* ---------- Search ---------- */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 16px;
  border-radius: 28px;
  background: var(--surface-2);
  margin-bottom: 12px;
  color: var(--on-surface-variant);
  transition: box-shadow 0.2s;
}
.search:focus-within { box-shadow: inset 0 0 0 2px var(--primary); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 16px;
  color: var(--on-surface);
}

/* ---------- Chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--outline-variant);
  text-decoration: none;
  color: var(--on-surface-variant);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.34s var(--ease-spring);
}
.chip.selected {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  border-color: transparent;
}
.chip:active { transform: scale(0.98); }

/* ---------- Tool grid and cards (varied corner radii) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 156px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  background: var(--surface-2);
  border-radius: 28px 10px 28px 10px;
  transition: transform 0.34s var(--ease-spring), background 0.34s;
}
.tool-card:nth-child(4n + 2) { border-radius: 10px 28px 10px 28px; }
.tool-card:nth-child(4n + 3) { border-radius: 24px 24px 6px 24px; }
.tool-card:nth-child(4n)     { border-radius: 6px 24px 24px 24px; }
.tool-card:active { transform: scale(0.98); }

.tool-card.cat-students   { background: var(--primary-container); color: var(--on-primary-container); }
.tool-card.cat-developers { background: var(--secondary-container); color: var(--on-secondary-container); }
.tool-card.cat-everyday   { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.tool-card.cat-creators   { background: var(--surface-3); color: var(--on-surface); }

.tool-card .tool-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--surface);
  color: var(--primary);
}
.tool-card h3 {
  margin: auto 0 0;
  font-size: 16px;
  font-weight: 600;
}
.tool-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.8;
}

.grid .empty { grid-column: 1 / -1; }

/* ---------- Empty and notice states ---------- */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--on-surface-variant);
}
.empty .ms { font-size: 48px; margin-bottom: 8px; }
.empty p { margin: 0; }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.4;
  background: var(--surface-2);
  color: var(--on-surface);
}
.notice.error { background: var(--error-container); color: var(--on-error-container); }
.notice.ok    { background: var(--secondary-container); color: var(--on-secondary-container); }

/* ---------- Tool page ---------- */
.tool-desc {
  margin: 4px 0 16px;
  color: var(--on-surface-variant);
  line-height: 1.45;
}
.tool-body { display: flex; flex-direction: column; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }

/* ---------- Buttons (different sizes and shapes) ---------- */
.btn {
  height: 48px;
  padding: 0 22px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.34s var(--ease-spring), background 0.2s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn.lg { height: 56px; padding: 0 28px; font-size: 16px; border-radius: 28px 16px 28px 16px; }
.btn.xl { height: 88px; padding: 0 44px; font-size: 20px; border-radius: 44px; }
.btn.filled  { background: var(--primary); color: var(--on-primary); }
.btn.tonal   { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.outlined { box-shadow: inset 0 0 0 1px var(--outline); }
.btn:hover.filled { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* ---------- Text fields ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--on-surface-variant);
}
.field input,
.field textarea {
  height: 56px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid var(--outline);
  background: var(--surface-1);
  font-size: 16px;
  color: var(--on-surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea {
  height: auto;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.5;
}
.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.field.area textarea { min-height: 180px; }

/* ---------- Slider ---------- */
.slider input[type="range"] {
  width: 100%;
  height: 32px;
  accent-color: var(--primary);
  background: none;
}
.slider > span {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--on-surface-variant);
}

/* ---------- Switches ---------- */
.switches {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 16px;
  border-radius: 24px;
  background: var(--surface-1);
}
.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
  font-size: 15px;
}
.switch-row input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: 16px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 2px var(--outline);
  cursor: pointer;
  transition: background 0.34s var(--ease-spring);
}
.switch-row input::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--outline);
  transition: transform 0.34s var(--ease-spring), width 0.2s, height 0.2s, background 0.2s;
}
.switch-row input:checked {
  background: var(--primary);
  box-shadow: none;
}
.switch-row input:checked::after {
  transform: translateX(20px);
  top: 4px;
  width: 24px;
  height: 24px;
  background: var(--on-primary);
}

/* ---------- Segmented button ---------- */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 20px;
  background: var(--surface-3);
}
.seg {
  flex: 1;
  height: 44px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.34s var(--ease-spring);
}
.seg.selected {
  background: var(--primary);
  color: var(--on-primary);
}
.seg:active { transform: scale(0.98); }

/* ---------- Result card ---------- */
.result-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  border-radius: 28px 28px 8px 28px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}
.res-val {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.02em;
  word-break: break-all;
}
.res-lbl { font-size: 14px; opacity: 0.85; }

/* ---------- Stats (word counter) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface-2);
}
.stat b { font-size: 28px; }
.stat span { font-size: 13px; color: var(--on-surface-variant); }
.hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
  color: var(--on-surface-variant);
}

/* ---------- Timer (organic blob shape that breathes while running) ---------- */
.timer {
  display: grid;
  place-items: center;
  width: min(260px, 70vw);
  aspect-ratio: 1;
  margin: 12px auto;
  border-radius: 60% 40% 55% 45% / 50% 55% 45% 50%;
  background: var(--tertiary-container);
  color: var(--on-tertiary-container);
  transition: border-radius 0.42s var(--ease-std);
}
.timer .time {
  font-size: 60px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.timer.running { animation: breathe 4s ease-in-out infinite; }
.timer.done { animation: pulse 0.4s ease-in-out 3; }
@keyframes breathe {
  50% { transform: scale(1.03); }
}
@keyframes pulse {
  50% { transform: scale(1.06); }
}

/* ---------- Password and output boxes ---------- */
.pw-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 12px 18px;
  border-radius: 24px 8px 24px 8px;
  background: var(--primary-container);
  color: var(--on-primary-container);
}
.pw-out {
  flex: 1;
  min-height: 28px;
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 18px;
  word-break: break-all;
}

.output-box {
  padding: 16px;
  border-radius: 24px;
  background: var(--surface-1);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Bottom navigation (Android-style pill indicator) ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface-2);
  border-radius: 28px 28px 0 0;
}
.nav-item {
  min-width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--on-surface-variant);
}
.nav-item .pill {
  width: 64px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  transition: background 0.34s var(--ease-spring), transform 0.34s var(--ease-spring);
}
.nav-item.active .pill {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  transform: scale(1.05);
}
.nav-item.active { color: var(--on-surface); font-weight: 600; }
.nav-item:active .pill { transform: scale(0.98); }

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

/* ---------- Wider screens ---------- */
@media (min-width: 720px) {
  .bottom-nav {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(560px, 100%);
    border-radius: 28px 28px 28px 28px;
    bottom: 12px;
  }
}

/* ==========================================================
   v2 additions
   ========================================================== */
.grow { flex: 1; min-width: 0; }
.small { font-size: 13px; margin: 0; }
.muted { color: var(--on-surface-variant); }
.mono { font-family: "Roboto Mono", ui-monospace, monospace; font-size: 14px; word-break: break-all; }
.btn.sm { height: 40px; padding: 0 14px; font-size: 13px; border-radius: 14px; }

.field select {
  height: 56px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid var(--outline);
  background: var(--surface-1);
  font-size: 16px;
  color: var(--on-surface);
  outline: none;
}
.field select:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.field input[type="color"] { padding: 6px; cursor: pointer; }

mark {
  background: var(--tertiary-container);
  color: var(--on-tertiary-container);
  border-radius: 4px;
  padding: 0 2px;
}
.regex-row { align-items: flex-end; }
.flags { width: 96px; flex: none; }
.msg:empty { display: none; }

.color-hero input[type="color"] {
  width: 100%;
  height: 120px;
  padding: 0;
  border: 0;
  border-radius: 28px 10px 28px 10px;
  background: none;
  cursor: pointer;
}
.color-hero input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-hero input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 28px 10px 28px 10px; }

.gradient-preview {
  height: 180px;
  border-radius: 32px 10px 32px 10px;
  background: var(--primary-container);
}

.flashcard {
  width: 100%;
  min-height: 210px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  border-radius: 32px 12px 32px 12px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  transition: transform 0.34s var(--ease-spring), background 0.34s;
}
.flashcard.back {
  background: var(--tertiary-container);
  color: var(--on-tertiary-container);
  border-radius: 12px 32px 12px 32px;
}
.flashcard:active { transform: scale(0.98); }
.fc-side { font-size: 13px; font-weight: 600; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.05em; }
.fc-text { font-size: 22px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.fc-count { font-size: 12px; opacity: 0.7; }

.result-card { animation: pop 0.34s var(--ease-spring); }
@keyframes pop {
  from { transform: scale(0.9); opacity: 0; }
}

/* ==========================================================
   v2.1: color themes, settings sheet, accessibility options
   ========================================================== */

/* Color themes: each one overrides the primary family in light and dark. */
html[data-palette="ocean"][data-theme="light"] {
  --primary: #00658f; --on-primary: #ffffff;
  --primary-container: #c4e7ff; --on-primary-container: #001e2e;
  --secondary-container: #d2e4f0; --on-secondary-container: #0b1e2a;
  --tertiary-container: #cfe9e0; --on-tertiary-container: #042017;
  --focus: #00658f;
}
html[data-palette="ocean"][data-theme="dark"] {
  --primary: #8ccdf4; --on-primary: #00344d;
  --primary-container: #004c6d; --on-primary-container: #c4e7ff;
  --secondary-container: #2c4a5c; --on-secondary-container: #d2e4f0;
  --tertiary-container: #1e4d3f; --on-tertiary-container: #cfe9e0;
  --focus: #8ccdf4;
}
html[data-palette="forest"][data-theme="light"] {
  --primary: #3b6a2f; --on-primary: #ffffff;
  --primary-container: #c5f0b0; --on-primary-container: #0e2306;
  --secondary-container: #dbe8d0; --on-secondary-container: #14200b;
  --tertiary-container: #fde9b5; --on-tertiary-container: #2a1d00;
  --focus: #3b6a2f;
}
html[data-palette="forest"][data-theme="dark"] {
  --primary: #a8d68f; --on-primary: #163a0a;
  --primary-container: #2d5121; --on-primary-container: #c5f0b0;
  --secondary-container: #3d4b37; --on-secondary-container: #dbe8d0;
  --tertiary-container: #5a4500; --on-tertiary-container: #fde9b5;
  --focus: #a8d68f;
}
html[data-palette="rose"][data-theme="light"] {
  --primary: #a4325a; --on-primary: #ffffff;
  --primary-container: #ffd9e2; --on-primary-container: #3f0019;
  --secondary-container: #f2dde4; --on-secondary-container: #2c1420;
  --tertiary-container: #e8deff; --on-tertiary-container: #20004d;
  --focus: #a4325a;
}
html[data-palette="rose"][data-theme="dark"] {
  --primary: #ffb0c8; --on-primary: #5e0b30;
  --primary-container: #7d2046; --on-primary-container: #ffd9e2;
  --secondary-container: #5a3e48; --on-secondary-container: #f2dde4;
  --tertiary-container: #4a2f7a; --on-tertiary-container: #e8deff;
  --focus: #ffb0c8;
}
html[data-palette="amber"][data-theme="light"] {
  --primary: #8a5a00; --on-primary: #ffffff;
  --primary-container: #ffdea8; --on-primary-container: #2c1a00;
  --secondary-container: #efe0cf; --on-secondary-container: #2a1a06;
  --tertiary-container: #cfe7d2; --on-tertiary-container: #072010;
  --focus: #8a5a00;
}
html[data-palette="amber"][data-theme="dark"] {
  --primary: #f5bf5c; --on-primary: #442b00;
  --primary-container: #634100; --on-primary-container: #ffdea8;
  --secondary-container: #52432f; --on-secondary-container: #efe0cf;
  --tertiary-container: #2e5438; --on-tertiary-container: #cfe7d2;
  --focus: #f5bf5c;
}

/* Accessibility */
html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}
html.large-text { font-size: 115%; }

/* Settings sheet (native dialog as a bottom sheet) */
dialog.sheet {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0 auto;
  width: min(560px, 100%);
  max-height: 88dvh;
  overflow: hidden;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--surface-1);
  color: var(--on-surface);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog.sheet[open] { animation: sheet-in 0.34s var(--ease-spring); }
@keyframes sheet-in {
  from { transform: translateY(40px); opacity: 0; }
}
.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 2px;
  background: var(--outline-variant);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 700; }
.set-group { margin: 18px 0; }
.set-group h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}
.swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 2px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--surface-2);
  transition: transform 0.34s var(--ease-spring), box-shadow 0.2s;
}
.swatch .dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c);
}
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--primary); }
.swatch:active { transform: scale(0.98); }

.list-row {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-radius: 20px;
  background: var(--surface-2);
  text-align: left;
  font-size: 15px;
  transition: background 0.2s;
}
.list-row .end { margin-left: auto; }
.list-row.danger { color: var(--error); background: var(--error-container); color: var(--on-error-container); }

.about {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
  text-align: center;
}
.about h2 { margin: 0; font-size: 28px; font-weight: 800; }
.about p { margin: 0; line-height: 1.5; }
.about-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  font-size: 32px;
  border-radius: 24px 8px 24px 8px;
  background: var(--primary-container);
  color: var(--on-primary-container);
}
.about-facts {
  width: 100%;
  margin: 8px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.about-facts div {
  padding: 12px 8px;
  border-radius: 18px;
  background: var(--surface-2);
}
.about-facts dt { font-size: 12px; color: var(--on-surface-variant); }
.about-facts dd { margin: 4px 0 0; font-size: 14px; font-weight: 600; }

.btn.danger { box-shadow: inset 0 0 0 1px var(--error); color: var(--error); }
.study-nav[hidden], .study-del[hidden] { display: none !important; }

/* v3: offline banner */
.offline-banner {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 72px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 20px 8px 20px 8px;
  background: var(--tertiary-container);
  color: var(--on-tertiary-container);
  font-size: 14px;
  animation: pop 0.34s var(--ease-spring);
}

/* ==========================================================
   v4 additions
   ========================================================== */
img.about-mark { display: block; width: 72px; height: 72px; border-radius: 22%; background: none; }

.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.calc-key { height: 52px; padding: 0; border-radius: 16px; font-size: 15px; font-weight: 600; font-family: "Roboto Mono", ui-monospace, monospace; }
.calc-key.wide { grid-column: 1 / -1; height: 60px; font-size: 20px; border-radius: 24px 10px 24px 10px; font-family: inherit; }

.grade-row { align-items: flex-end; }
.grade-row .icon-btn { flex: none; margin-bottom: 4px; }
.section-title { margin: 8px 0 0; font-size: 15px; font-weight: 700; color: var(--primary); }
.field-label { font-size: 13px; color: var(--on-surface-variant); }
.stat b { word-break: break-all; }
.stat b.mono { font-size: 20px; }
.note-card { padding: 14px 16px; border-radius: 24px 8px 24px 8px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.note-card h3 { margin: 0; font-size: 16px; }
.note-card p { margin: 0; white-space: pre-wrap; word-break: break-word; color: var(--on-surface-variant); }
.note-list { display: flex; flex-direction: column; gap: 10px; }

.diff { border-radius: 20px; background: var(--surface-1); padding: 10px 0; overflow-x: auto; font-size: 13px; }
.diff-line { display: block; padding: 2px 12px; white-space: pre-wrap; word-break: break-all; }
.diff-line.add { background: var(--secondary-container); color: var(--on-secondary-container); }
.diff-line.del { background: var(--error-container); color: var(--on-error-container); }
.pass { color: var(--primary); font-weight: 700; }
.fail { color: var(--error); font-weight: 700; }
.contrast-sample { padding: 24px; border-radius: 24px 8px 24px 8px; font-size: 22px; font-weight: 600; text-align: center; border: 1px solid var(--outline-variant); }
pre.output-box { margin: 0; overflow-x: auto; }

.md-preview { padding: 16px; border-radius: 24px 8px 24px 8px; background: var(--surface-1); line-height: 1.6; word-break: break-word; }
.md-preview h1, .md-preview h2, .md-preview h3 { margin: 0.4em 0 0.3em; line-height: 1.2; }
.md-preview p { margin: 0.5em 0; }
.md-preview code { font-family: "Roboto Mono", monospace; background: var(--surface-3); padding: 0 4px; border-radius: 6px; }
.md-preview a { color: var(--primary); }
.md-preview ul { padding-left: 20px; margin: 0.4em 0; }

.stopwatch .time { font-size: 40px; }
.laps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.laps li { display: flex; justify-content: space-between; padding: 10px 16px; border-radius: 16px; background: var(--surface-2); }

.meter { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 5px; transition: width 0.34s var(--ease-std); }
.meter.over span { background: var(--error); }

.swatch-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.chip-color { height: 96px; border-radius: 20px 8px 20px 8px; padding: 6px; display: flex; align-items: flex-end; justify-content: center; font-family: "Roboto Mono", monospace; font-size: 11px; font-weight: 600; border: 0; transition: transform 0.34s var(--ease-spring); }
.chip-color:active { transform: scale(0.98); }

.preview-box { height: 200px; display: grid; place-items: center; border-radius: 24px 8px 24px 8px; background: var(--surface-2); overflow: hidden; }
.preview-shape { width: 130px; height: 130px; background: var(--primary); transition: border-radius 0.34s var(--ease-std), box-shadow 0.34s var(--ease-std); }

.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.sym-btn { height: 52px; border-radius: 14px; font-size: 20px; background: var(--surface-2); transition: transform 0.34s var(--ease-spring); }
.sym-btn:active { transform: scale(0.98); }

.type-ref { margin: 0; padding: 16px; border-radius: 20px; background: var(--surface-1); line-height: 1.6; font-size: 17px; }
.chmod table { width: 100%; border-collapse: collapse; }
.chmod th, .chmod td { padding: 6px 4px; text-align: center; font-weight: 600; }
.chmod td:first-child { text-align: left; }
.chmod input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--primary); cursor: pointer; }

.md-grid-wrap { overflow-x: auto; }
.md-grid { display: grid; gap: 6px; min-width: 100%; }
.md-grid input { height: 44px; min-width: 0; padding: 0 10px; border-radius: 12px; border: 1px solid var(--outline); background: var(--surface-1); color: var(--on-surface); font: inherit; font-size: 15px; outline: none; }
.md-grid input:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

.diff-inputs textarea { min-height: 120px; }
.small { font-size: 13px; margin: 0; }
.muted { color: var(--on-surface-variant); }

/* v4.1: consistent spacing between results, notices and stat cards */
.out { display: flex; flex-direction: column; gap: 12px; }
.out:empty { display: none; }
.out > .stats { margin: 0; }

/* v5: one neutral surface for all tool cards, and instant theme switching */
.tool-card.cat-students,
.tool-card.cat-developers,
.tool-card.cat-everyday,
.tool-card.cat-creators {
  background: var(--surface-2);
  color: var(--on-surface);
}
html.no-transition *,
html.no-transition *::before,
html.no-transition *::after {
  transition: none !important;
  animation: none !important;
}

/* v5: tool-specific layouts */
.cron-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cron-fields .field:last-child { grid-column: 1 / -1; }
.cron-explain { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.cron-explain li { padding: 10px 14px; border-radius: 16px; background: var(--surface-2); font-size: 14px; }
.status-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.status-list li { padding: 12px 16px; border-radius: 18px 6px 18px 6px; background: var(--surface-2); display: grid; grid-template-columns: 64px 1fr; gap: 4px 12px; }
.status-list b { font-size: 18px; color: var(--primary); }
.status-list span { font-size: 14px; color: var(--on-surface-variant); }
.gpa-rows .grade-row select { height: 56px; border-radius: 16px; border: 1px solid var(--outline); background: var(--surface-1); color: var(--on-surface); padding: 0 12px; font: inherit; font-size: 16px; }
.dice-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.die { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px 6px 16px 6px; background: var(--primary-container); color: var(--on-primary-container); font-size: 22px; font-weight: 700; }
.preview-grid { display: grid; min-height: 180px; padding: 12px; border-radius: 24px 8px 24px 8px; background: var(--surface-1); }
.preview-grid span { min-height: 36px; border-radius: 10px; background: var(--primary); }
.preview-flex { display: flex; height: 200px; padding: 12px; border-radius: 24px 8px 24px 8px; background: var(--surface-1); }
.preview-flex span { min-width: 44px; min-height: 44px; border-radius: 12px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; }
.countdown .time { font-size: 44px; }
.unicode-card { padding: 12px 16px; border-radius: 20px 6px 20px 6px; background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; }
.unicode-card b { font-size: 28px; }
.unicode-card span { font-size: 13px; color: var(--on-surface-variant); word-break: break-all; }

/* v5.2: the header stays fixed while the options scroll; rows are spaced apart */
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 8px;
}
.set-group .list-row + .list-row { margin-top: 8px; }

/* v5.3: closed sheets must stay hidden; only an open sheet uses flex layout */
dialog.sheet:not([open]) { display: none; }
dialog.sheet[open] { display: flex; flex-direction: column; }

/* v5.3: closed dialogs stay hidden; the sheet only becomes a flex box when open */
dialog.sheet:not([open]) { display: none; }
dialog.sheet[open] { display: flex; }

/* ==========================================================
   v6 typography system (Material 3 type roles)
   Font: Google Sans Flex (OFL), falls back to system fonts.
   Sizes are rem, so "Larger text" scales the whole interface.
   ========================================================== */
:root {
  --font-ui: "Google Sans Flex", "Google Sans", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type roles: weight size/line-height family */
  --type-display: 600 2.25rem/2.75rem var(--font-ui);
  --type-headline: 600 1.625rem/2.125rem var(--font-ui);
  --type-title-lg: 600 1.25rem/1.75rem var(--font-ui);
  --type-title-md: 600 1rem/1.5rem var(--font-ui);
  --type-body-lg: 400 1rem/1.5rem var(--font-ui);
  --type-body-md: 400 0.875rem/1.25rem var(--font-ui);
  --type-label-lg: 600 0.875rem/1.25rem var(--font-ui);
  --type-label-md: 600 0.75rem/1rem var(--font-ui);
  --type-number: 700 2.25rem/2.75rem var(--font-ui);
}

body { font-family: var(--font-ui); font-optical-sizing: auto; }
h1, h2, h3 { text-wrap: balance; }

.app-bar h1 { font: var(--type-title-lg); letter-spacing: 0; }
.hero h2 { font: var(--type-display); letter-spacing: -0.01em; }
.hero p { font: var(--type-body-lg); }
.sheet-head h2 { font: var(--type-title-lg); }
.about h2 { font: var(--type-headline); letter-spacing: 0; }
.about p:not(.muted) { font: var(--type-body-lg); }
.about-facts dt { font: var(--type-label-md); }
.about-facts dd { font: var(--type-label-lg); margin-top: 4px; }

.search input, .field input, .field textarea, .field select { font: var(--type-body-lg); letter-spacing: 0.01em; }
.field > span, .field-label { font: var(--type-label-md); letter-spacing: 0.02em; }
.nav-item { font: var(--type-label-md); }
.nav-item.active { font-weight: 600; }

.tool-card h3 { font: var(--type-title-md); letter-spacing: 0.005em; }
.tool-card p { font: var(--type-body-md); }
.tool-desc { font: var(--type-body-lg); }
.section-title, .note-card h3 { font: var(--type-title-md); }
.note-card p, .notice, .empty p, .small, .hint, .res-lbl, .stat span, .muted { font-size: 0.875rem; line-height: 1.25rem; }
.stat b { font: var(--type-title-lg); }
.stat b.mono, .pw-out, .diff, .output-box, pre.output-box, .mono { font-family: var(--font-mono); }

.btn { font: var(--type-label-lg); letter-spacing: 0.01em; }
.btn.lg { font: var(--type-title-md); }
.btn.xl { font: var(--type-title-md); font-size: 1.25rem; }
.seg { font: var(--type-label-lg); }
.list-row, .switch-row { font: var(--type-body-lg); }
.set-group h3 { font: var(--type-label-md); letter-spacing: 0.06em; }
.swatch { font: var(--type-label-md); }

.result-card .res-val, .res-val { font: var(--type-number); letter-spacing: -0.01em; }
.result-card .res-lbl { font: var(--type-body-md); }
.timer .time, .stopwatch .time, .countdown .time { font-family: var(--font-ui); font-weight: 700; }
.unicode-card b { font: var(--type-headline); }
.unicode-card span { font: var(--type-body-md); }
.status-list b { font: var(--type-title-lg); }
.status-list span { font-size: 0.875rem; }
.status-list strong { font-weight: 600; }

/* Nav labels and small helpers follow the same rem scale */
.nav-item { font-size: 0.75rem; }

/* ==========================================================
   v6 motion: view transition (opacity and transform only)
   ========================================================== */
.view-enter { animation: view-in 0.34s var(--ease-std) both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
}

.noscript { margin: 24px; padding: 16px; border-radius: 20px; background: var(--error-container); color: var(--on-error-container); }


/* v8: complete interaction states for form controls and rows */
.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  background: var(--surface-2);
}
.switch-row input:disabled { opacity: 0.38; cursor: not-allowed; }
.list-row:disabled,
.icon-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.list-row:not(:disabled):active,
.icon-btn:not(:disabled):active { background: var(--surface-3); }
.list-row:focus-visible,
.swatch:focus-visible,
.chip:focus-visible,
.seg:focus-visible,
.tool-card:focus-visible,
.nav-item:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* loading: a button that is waiting shows a small spinner and ignores taps */
.btn.loading { pointer-events: none; position: relative; color: transparent; }
.btn.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  color: var(--on-primary);
  animation: spin 0.8s linear infinite;
}
.btn.tonal.loading::after { color: var(--on-secondary-container); }
@keyframes spin { to { transform: rotate(360deg); } }

/* v10: full-screen settings and about pages */
body.no-nav { padding-bottom: env(safe-area-inset-bottom, 0px); }
.page { max-width: 720px; margin: 0 auto; padding: 4px 4px 32px; display: flex; flex-direction: column; }
.page .set-group { margin: 14px 0; }
.about { align-items: center; text-align: center; padding-top: 16px; }
img.about-mark { display: block; width: 96px; height: 96px; border-radius: 24px; background: #000; margin: 0 auto; }
.about-title { margin: 14px 0 0; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.about-text { margin: 8px 8px 0; line-height: 1.5; color: var(--on-surface-variant); }
.about .about-facts { width: 100%; margin: 20px 0 0; }

/* v11: sentence-case section labels, readable field labels */
.set-group h3, .section-title {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}
.field { font-size: 14px; }
.field > span, .field span { font-size: 14px; }

/* v11: in-app logo has a transparent background, so it sits on the page without a frame */
img.about-mark { background: none; border-radius: 0; width: 96px; height: 96px; }

