/* Page frame: header, quick start, behaviour, footer and the sticky bottom bar. */
.page { max-width: 1080px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
.brand { min-width: 0; }
/* On phones the brand/actions gap is one step smaller so the wider 日本語 language key still leaves the wordmark its full width. */
@media (max-width: 420px) { .topbar-inner { gap: var(--sp-1); } }
.wordmark { white-space: nowrap; font: 600 28px/32px var(--mono); letter-spacing: 0.02em; color: var(--accent-strong); }
.tagline { color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); }
.topbar-actions { display: flex; gap: var(--sp-1); flex: none; }
/* Language button: the short label (EN, 日本語) sits in a key as wide as its text; the menu drops down from it. */
.topbar-actions .lang-btn { padding: 0 var(--sp-1); font-size: var(--fs-small); white-space: nowrap; }
.menu.lang-menu { top: calc(100% + var(--sp-1)); bottom: auto; left: 0; right: auto; min-width: 160px; }
.lang-menu[hidden] { display: none; }
.lang-item { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.lang-item[aria-checked="true"] { color: var(--accent-strong); }
.lang-item[aria-checked="true"]::after { content: ""; flex: none; width: 8px; height: 3px; border-radius: 2px; background: var(--accent); }

.main { display: grid; gap: var(--sp-4); padding-bottom: calc(var(--bar-h) + var(--sp-4)); }
.main > * { min-width: 0; }

.pills { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 1px solid var(--key-edge);
  border-radius: var(--radius-s);
  background: var(--key);
  box-shadow: inset 0 1px 0 var(--key-hi), var(--key-drop);
  font-weight: 500;
  transition: transform var(--press), box-shadow var(--press), background var(--press);
}
/* The mark slot is always there (key-edge colour) so the label does not shift when a preset is selected. */
.pill::before { content: ""; flex: none; width: 8px; height: 3px; border-radius: 2px; background: var(--key-edge); }
.pill:hover { background: var(--key-hover); }
.pill:active { transform: translateY(1px); box-shadow: inset 0 1px 0 var(--key-hi); }
.pill[aria-pressed="true"] { background: var(--surface-2); box-shadow: var(--well-shade); }
.pill[aria-pressed="true"]::before { background: var(--accent); }
.quick-desc { color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); min-height: var(--lh-small); margin-top: var(--sp-1); }
@media (max-width: 767px) { .pills { display: grid; grid-template-columns: repeat(3, 1fr); } .pill { padding: 0 var(--sp-1); } }

.behaviour { display: grid; gap: var(--sp-2); }
.options { display: grid; gap: var(--sp-1); grid-template-columns: 1fr 1fr; }
.option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-1);
  min-height: 72px;
  padding: var(--sp-1) var(--sp-2);
  text-align: left;
  background: var(--key);
  border: 1px solid var(--key-edge);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--key-hi), var(--key-drop);
  transition: transform var(--press), box-shadow var(--press), background var(--press);
}
.option:hover { background: var(--key-hover); }
.option:active { transform: translateY(1px); box-shadow: inset 0 1px 0 var(--key-hi); }
.option-text { display: grid; gap: 2px; min-width: 0; }
/* Device label: small all-caps, set in CSS so the locale strings stay normal case. */
.option-label { font-size: var(--fs-caption); line-height: var(--lh-caption); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); overflow-wrap: anywhere; }
.option-value { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--text); min-width: 0; }
.dot { flex: none; box-sizing: content-box; width: 6px; height: 6px; border-radius: 50%; }
.dot-on { background: var(--accent); border: 1px solid var(--accent-edge); }
.dot-off { border: 1.5px solid var(--muted); }
.option > .icon { color: var(--muted); }
@media (min-width: 1024px) { .options { grid-template-columns: repeat(4, 1fr); } }

/* Footer */
.end { display: grid; gap: var(--sp-1); }
.issues-strip { display: grid; gap: 4px; }
.advanced-panel { display: grid; gap: var(--sp-2); padding: var(--sp-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.adv-toggle { display: flex; align-items: center; gap: var(--sp-1); min-height: var(--tap); flex: 1; min-width: 0; background: none; border: 0; padding: 0 12px; margin-left: -12px; text-align: left; font-weight: 500; border-radius: var(--radius-s); transition: background var(--press); }
.adv-toggle:hover { background: var(--surface-2); }
.adv-toggle > .icon { color: var(--muted); }
.adv-toggle .muted { font-weight: 400; }
.footer-actions { position: relative; display: flex; align-items: center; gap: var(--sp-1); flex: none; }
.loop { display: grid; margin-right: var(--sp-1); color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); }
.loop > span:first-child { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); }
/* The loop time sits in a small recessed number window. */
.loop b { padding: 4px 10px; border: 1px solid var(--well-edge); border-radius: var(--radius-s); background: var(--well); box-shadow: var(--well-shade); font: 500 var(--fs-body)/var(--lh-small) var(--mono); font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.loop-error { color: var(--danger); font-size: var(--fs-caption); line-height: var(--lh-caption); }
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + var(--sp-1));
  z-index: 40;
  min-width: 200px;
  display: grid;
  padding: 4px;
  background: var(--key);
  border: 1px solid var(--key-edge);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--key-hi), 0 8px 24px var(--shadow);
}
.menu-item { min-height: var(--tap); padding: 0 var(--sp-2); text-align: left; font-weight: 500; background: none; border: 0; border-radius: var(--radius-s); }
.menu-item:hover:not(:disabled) { background: var(--key-hover); }
.menu-item:active:not(:disabled) { background: var(--surface-2); }
.menu-item:disabled { color: var(--muted); cursor: not-allowed; }
.menu-note { padding: 4px var(--sp-2) var(--sp-1); color: var(--muted); font-size: var(--fs-caption); line-height: var(--lh-caption); max-width: 240px; }

@media (max-width: 1199px) {
  .footer-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    height: var(--bar-h);
    justify-content: flex-end;
    padding: 0 var(--gutter);
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .footer-actions .loop { flex: 1; margin-right: 0; min-width: 0; }
}
@media (min-width: 1200px) { .main { padding-bottom: var(--sp-4); } }

/* About / disclaimer at the end of the page. */
.about { border-top: 1px solid var(--line); padding-top: var(--sp-3); max-width: 68ch; color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-small); }
.about h2 { color: var(--text); font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 600; margin: 0 0 var(--sp-1); }
.about p { margin: 0 0 var(--sp-1); }
.about p:last-child { margin-bottom: 0; }
.about a { color: var(--accent-strong); text-underline-offset: 3px; }
.about p:last-child a { display: inline-flex; align-items: center; min-height: var(--tap); }
