/* multitask-timer — styles
   Layout targets: desktop Chrome and iPad Safari (touch first, no hover dependency).
   The whole card is the start/stop control, so nothing inside it may look tappable
   except the per-task menu button. */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #2563eb;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-run: 0 6px 22px rgba(16, 24, 40, .16);
  --radius: 16px;

  /* Per-task tints: soft red / blue / yellow / green / purple / orange.
     `--strong` is only used while the task is running. */
  --t0-tint: #fff2f2;  --t0-edge: #f3bcbc;  --t0-strong: #e77b7b;
  --t1-tint: #eff4ff;  --t1-edge: #bacff5;  --t1-strong: #7ba2ee;
  --t2-tint: #fff9e8;  --t2-edge: #f0d99e;  --t2-strong: #d9a93f;
  --t3-tint: #eefaf1;  --t3-edge: #b0dfbc;  --t3-strong: #6fc389;
  --t4-tint: #f6f1ff;  --t4-edge: #cbbcf2;  --t4-strong: #9d81e6;
  --t5-tint: #fff4ea;  --t5-edge: #f5c8a3;  --t5-strong: #ec9d5f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --card: #1c2027;
    --text: #e8eaed;
    --muted: #9aa3ae;
    --border: #2c323b;
    --accent: #60a5fa;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .25);
    --shadow-run: 0 6px 22px rgba(0, 0, 0, .45);

    --t0-tint: #2b1e20;  --t0-edge: #6d4247;  --t0-strong: #d97f7f;
    --t1-tint: #1b2130;  --t1-edge: #3f5480;  --t1-strong: #7ba2ee;
    --t2-tint: #2a2519;  --t2-edge: #6e5c34;  --t2-strong: #d9b45c;
    --t3-tint: #1a2620;  --t3-edge: #3d6349;  --t3-strong: #66bd80;
    --t4-tint: #241f31;  --t4-edge: #52447d;  --t4-strong: #9d81e6;
    --t5-tint: #2b2119;  --t5-edge: #6f5136;  --t5-strong: #e09a63;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  overscroll-behavior-x: none;   /* a sideways trackpad scroll turns the page, not "back" */
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
               "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  padding: 10px 14px 14px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Touch behaviour: no double-tap zoom, no text selection on repeated taps. */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- header ---------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* App name + version: the same look in every yukmmz.github.io app. */
.app-brand {
  display: flex;
  align-items: baseline;
  gap: .45em;
  white-space: nowrap;
}

.app-title {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  letter-spacing: .02em;
  line-height: 1.2;
  white-space: nowrap;
}

.app-version {
  font-size: 11px;
  font-weight: 400;
  opacity: .55;
  white-space: nowrap;
}

.total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
}

.total-label { font-size: .8rem; color: var(--muted); }

.total-time {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; }

.btn-stop {
  font-weight: 600;
  white-space: nowrap;
}

.btn-stop:not(:disabled) {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn-ghost { color: var(--muted); font-size: .9rem; }

.btn-danger {
  color: var(--danger);
  border-color: var(--border);
  font-size: .9rem;
}

.btn-round {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* The settings gear is the one control that must read at a glance. */
#settings-btn {
  font-size: 2.1rem;
  line-height: 1;
  overflow: visible;
}

/* ---------- task grid ---------- */

/* Cards beside the (optional) page list. */
.workspace {
  flex: 1 1 auto;
  display: flex;
  gap: 12px;
  min-height: 0;
}

main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;   /* the row of cards sits mid-height, not top-aligned */
  padding: 14px 0;
}

/* Cards use the full width side by side; each one is a square. */
.tasks {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: clamp(6px, 1vw, 14px);
  align-items: center;
}

/* ---------- task card (the whole card is the toggle) ---------- */

.card {
  position: relative;
  /* Square cards. `width` caps them so a single task does not fill the page. */
  aspect-ratio: 1 / 1;
  width: min(100%, 62vh);
  justify-self: center;
  background: var(--tint, var(--card));
  border: 2px solid var(--edge, var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(6px, 1.1vw, 14px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: border-color .12s ease, box-shadow .12s ease, transform .06s ease;
}

/* Reordering: long-press lifts the card; the card under the finger shows where it will go. */
.card.dragging {
  z-index: 30;
  box-shadow: var(--shadow-run);
  opacity: .92;
  transition: none;
  cursor: grabbing;
}
/* The other cards slide to where they would land if the held card were dropped now. */
.tasks.reordering .card:not(.dragging) { transition: transform .18s ease; }
.card { -webkit-touch-callout: none; }

[data-color="0"] { --tint: var(--t0-tint); --edge: var(--t0-edge); --strong: var(--t0-strong); }
[data-color="1"] { --tint: var(--t1-tint); --edge: var(--t1-edge); --strong: var(--t1-strong); }
[data-color="2"] { --tint: var(--t2-tint); --edge: var(--t2-edge); --strong: var(--t2-strong); }
[data-color="3"] { --tint: var(--t3-tint); --edge: var(--t3-edge); --strong: var(--t3-strong); }
[data-color="4"] { --tint: var(--t4-tint); --edge: var(--t4-edge); --strong: var(--t4-strong); }
[data-color="5"] { --tint: var(--t5-tint); --edge: var(--t5-edge); --strong: var(--t5-strong); }

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

.card.running {
  border-color: var(--strong, var(--accent));
  box-shadow: var(--shadow-run), inset 0 0 0 2px var(--strong, var(--accent));
}

/* Everything the card shows lives here, and scales with the card's own width.
   `cqi` = 1% of this container's inline size, so 6 small cards shrink their
   text instead of overflowing. The clamp() fallbacks keep older browsers sane. */
.card-body {
  container-type: inline-size;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-top {
  display: flex;
  align-items: center;
  gap: clamp(3px, 2cqi, 8px);
  flex: 0 0 auto;
}

@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
}

.task-name-text {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  font-size: .95rem;
  font-size: clamp(.6rem, 7.5cqi, 1.15rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-menu-btn {
  background: rgba(255, 255, 255, .7);
  border-color: var(--edge, var(--border));
  width: clamp(20px, 14cqi, 36px);
  height: clamp(20px, 14cqi, 36px);
  border-radius: clamp(6px, 3cqi, 10px);
  font-size: clamp(.65rem, 7cqi, 1.1rem);
}

@media (prefers-color-scheme: dark) {
  .task-menu-btn { background: rgba(255, 255, 255, .06); }
}

.time-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2px;
  min-height: 0;
}

.task-time {
  font-size: 2rem;
  font-size: clamp(.8rem, 17cqi, 3.2rem);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  line-height: 1.1;
}

/* The running card colours its own clock; the tint plus the ring is the cue. */
.card.running .task-time {
  color: var(--strong, var(--accent));
  font-weight: 700;
}

/* Over the target time: red and bold. Counting up does NOT stop. */
.task-time.over,
.card.running .task-time.over {
  color: var(--danger);
  font-weight: 800;
}

/* Target time: small and light, one line under the clock. */
.task-target-view {
  min-height: 1.2em;
  font-size: .78rem;
  font-size: clamp(.5rem, 5cqi, .82rem);
  font-weight: 300;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.task-over {
  min-height: 1.2em;
  font-size: .82rem;
  font-size: clamp(.5rem, 5.2cqi, .86rem);
  font-variant-numeric: tabular-nums;
  color: var(--danger);
  font-weight: 600;
}

/* ---------- per-task menu ---------- */

.task-menu {
  /* A centred modal, not an in-card popover: it must not be clipped by the
     square card, and tapping the backdrop is what closes it. */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 32px));
  z-index: 40;   /* above the shared backdrop (20) and the settings sheet (30) */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-run);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: default;
}

.task-menu[hidden] { display: none; }

.menu-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .8rem;
  color: var(--muted);
}

.menu-target {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.menu-unit { font-size: .85rem; }

.task-name,
.task-target-h,
.task-target-m {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  width: 100%;
  min-width: 0;
}

.task-target-h,
.task-target-m {
  width: 4.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.task-name:focus,
.task-target-h:focus,
.task-target-m:focus {
  outline: none;
  border-color: var(--accent);
}


/* ---------- footer ---------- */

/* Sum of every target time that is set. Deliberately as quiet as the per-card
   target line: it is a reference figure, not something to watch. */
.app-footer {
  flex: 0 0 auto;
  text-align: center;
  padding: 2px 0 4px;
}

.target-total {
  display: block;
  min-height: 1.2em;
  font-size: .78rem;
  font-weight: 300;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}


/* ---------- pages: ‹ name ●○○ › at the bottom ---------- */

.page-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-top: 2px;
}
.page-list-btn { justify-self: start; }
.page-list-btn.on { color: var(--accent); border-color: var(--accent); }
.pl-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.page-switch {
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-arrow { font-size: 1.6rem; }
.page-arrow:disabled { opacity: .3; }
.page-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 7em;
}
.page-name {
  max-width: 40vw;
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-dots { display: flex; gap: 6px; }
.page-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
}
.page-dot.current { background: var(--text); }
/* The page whose task is running, even while another page is shown. */
.page-dot.running { outline: 2px solid var(--accent); outline-offset: 1px; }
.page-name-input {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  width: 60%;
}

/* A page change slides the cards in from the side it came from. */
.tasks.slide-next { animation: slide-next .2s ease-out; }
.tasks.slide-prev { animation: slide-prev .2s ease-out; }
@keyframes slide-next { from { transform: translateX(28px); opacity: .3; } }
@keyframes slide-prev { from { transform: translateX(-28px); opacity: .3; } }

/* ---------- page list (slide-sorter style thumbnails) ---------- */

.page-list {
  flex: 0 0 210px;
  align-self: stretch;
  max-height: calc(100dvh - 150px);
  overflow-y: auto;
  padding: 10px 6px 10px 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.page-list[hidden] { display: none; }
.page-list-items { display: flex; flex-direction: column; gap: 10px; }
.page-thumb-item {
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* Reordering pages: the held thumbnail lifts; the others slide to make room. */
.page-thumb-item.dragging { z-index: 5; opacity: .92; cursor: grabbing; }
.page-thumb-item.dragging .page-thumb-body { box-shadow: var(--shadow-run); }
.page-list-items.reordering .page-thumb-item:not(.dragging) { transition: transform .18s ease; }
/* Delete (×) in the thumbnail's top-right corner; always visible (no hover on iPad). */
.page-thumb-delete {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 1rem;
  line-height: 22px;
  cursor: pointer;
}
.page-thumb-delete:hover { color: var(--danger); background: var(--bg); }
.page-thumb-item:has(.page-thumb-delete) .page-thumb-name { padding-right: 20px; }
.page-thumb {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.page-thumb-num {
  flex: 0 0 1.3em;
  padding-top: 4px;
  font-size: .78rem;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.page-thumb-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.page-thumb:hover .page-thumb-body { border-color: var(--muted); }
/* The page on screen: a thick frame, as in a slide sorter. */
.page-thumb.current .page-thumb-body { border: 3px solid var(--accent); padding: 5px; }
.page-thumb-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.2;
}
.page-thumb-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.page-thumb-run { flex: 0 0 auto; margin-left: auto; font-size: .66rem; font-weight: 700; color: var(--accent); }
.page-thumb-tasks {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 3px;
}
.page-thumb-task {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 2px 4px;
  background: var(--tint, var(--card));
  border: 1px solid var(--edge, var(--border));
  border-radius: 5px;
  font-size: .62rem;
  line-height: 1.3;
}
.page-thumb-task.running { border: 2px solid var(--strong, var(--accent)); padding: 1px 3px; }
.ptt-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ptt-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.page-thumb-task.running .ptt-time { color: var(--text); font-weight: 700; }
.page-list-add { align-self: center; font-size: .85rem; }
.page-list-add::before { content: '＋ '; }

/* ---------- target-time wheels (touch devices) ---------- */

/* The number fields and the wheels are two views of the same value. Which one
   shows depends on the pointer: a mouse types, a finger scrolls. */
.wheel-row { display: none; }

@media (pointer: coarse) {
  .menu-target { display: none; }

  .wheel-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
  }
}

/* No frame and no fill: the column has to disappear into the sheet, the way
   the iOS picker does. What marks the choice is the band, not a box. */
.wheel {
  position: relative;
  z-index: 1;
  height: 200px;            /* 5 rows of 40px */
  width: 58px;
  overflow-y: auto;
  /* proximity, not mandatory: a flick keeps its momentum instead of being
     caught by the next snap point. alignWheel() squares it up at rest. */
  scroll-snap-type: y proximity;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
  text-align: center;
  background: none;
  border: 0;
  /* Half the wheel minus half a row, so the first and last values can sit in
     the middle band. */
  padding: 80px 0;
  /* Rows dissolve towards the edges instead of being cut off by a border. */
  -webkit-mask-image: linear-gradient(to bottom,
      transparent 0%, #000 26%, #000 74%, transparent 100%);
  mask-image: linear-gradient(to bottom,
      transparent 0%, #000 26%, #000 74%, transparent 100%);
}

.wheel::-webkit-scrollbar { display: none; }

.wheel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

.wheel-item {
  height: 40px;
  line-height: 40px;
  scroll-snap-align: center;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  opacity: .55;
  transition: opacity .12s ease, font-size .12s ease;
}

.wheel-item.selected {
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 600;
  opacity: 1;
}

/* The band sits behind the numbers, has no edges, and is barely there — just
   enough contrast to say which row counts. It must not eat touches. */
.wheel-band {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 40px;
  transform: translateY(-50%);
  border-radius: 10px;
  background: rgba(20, 24, 32, .06);
  pointer-events: none;
  z-index: 0;
}

@media (prefers-color-scheme: dark) {
  .wheel-band { background: rgba(255, 255, 255, .08); }
}

/* The unit labels ride inside the band, as the iOS picker puts them. */
.wheel-row .menu-unit {
  position: relative;
  z-index: 1;
  font-size: .8rem;
}

/* ---------- settings sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(16, 24, 40, .35);
}

.backdrop[hidden] { display: none; }

.sheet {
  position: fixed;
  z-index: 30;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-run);
  padding: 16px;
}

.sheet[hidden] { display: none; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sheet-title { font-size: 1rem; margin: 0; }

.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.sheet-label { font-size: .9rem; }

.sheet-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.sound-select {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  max-width: 60%;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper-value {
  min-width: 1.6em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.sheet-help {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
  font-size: .85rem;
  color: var(--muted);
}

.sheet-help p { margin: 6px 0; }
.sheet-help .note { font-size: .8rem; margin-top: 10px; }

.sample-over { color: var(--danger); font-weight: 800; }

kbd, .kbd-like {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8em;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg);
}


/* ---------- QR overlay ---------- */

#qrOverlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 24, 40, .45);
}

#qrOverlay[hidden] { display: none; }

.qrcard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-run);
  padding: 20px;
  max-width: min(560px, calc(100vw - 32px));
  text-align: center;
}

.qrrow {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.qrcol { flex: 0 1 210px; }

.qrlabel {
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

/* The SVG is drawn on white; keep it that way in dark mode so it stays scannable. */
.qrImg {
  width: 100%;
  max-width: 190px;
  height: auto;
  background: #fff;
  border-radius: 8px;
}

.qrurl {
  font-size: .7rem;
  color: var(--muted);
  word-break: break-all;
  margin-top: 4px;
}

#qrClose { margin-top: 16px; }

/* ---------- changelog overlay ---------- */

#changelogOverlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 24, 40, .45);
}

#changelogOverlay[hidden] { display: none; }

#helpOverlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 24, 40, .45);
}

#helpOverlay[hidden] { display: none; }

.help-body { font-size: .9rem; line-height: 1.6; }
.help-body p { margin: 6px 0; }
.help-body .note, .help-body .hint { font-size: .8rem; color: var(--muted); }

#helpClose { margin-top: 12px; align-self: center; }

#help-btn { font-size: 1.35rem; font-weight: 700; }

/* "FB" packed edge to edge inside the 36x36 key: bold, squeezed sideways, no extra spacing. */
#feedback-btn .fb-mark {
  display: inline-block;
  font-size: 1.44rem;
  font-weight: 384;
  letter-spacing: -.05em;
  line-height: 1;
  transform: scaleX(.74);
}

/* ---------- feedback overlay ---------- */

#feedbackOverlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 24, 40, .45);
}

#feedbackOverlay[hidden] { display: none; }

.feedback-card { gap: 8px; }
.feedback-lead, .feedback-note { margin: 0; font-size: .85rem; color: var(--muted); }
.feedback-message, .feedback-contact {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: .95rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg, #fff);
  color: inherit;
}
.feedback-message { resize: vertical; min-height: 120px; }
.feedback-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.feedback-status { margin: 0; min-height: 1.2em; font-size: .85rem; font-weight: 700; }
.feedback-status.ok { color: #15803d; }
.feedback-status.err { color: #dc2626; }
.feedback-actions { display: flex; gap: 8px; justify-content: flex-end; }

.changelog-card {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  text-align: left;
}

.changelog-title { font-size: 1rem; margin: 0 0 8px; }

.changelog-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
}

.changelog-entry + .changelog-entry {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 8px;
}

.changelog-version { font-size: .9rem; margin: 0 0 4px; }

.changelog-entry ul {
  margin: 0;
  padding-left: 1.2em;
  font-size: .85rem;
  color: var(--muted);
}

#changelogClose { margin-top: 12px; align-self: center; }

/* A small dot on ⚙ and on the changelog button until the new version's
 * changelog has been opened once. */
#settings-btn, #changelogBtn { position: relative; }

#settings-btn.has-news::after,
#changelogBtn.has-news::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
}

/* ---------- narrow screens ---------- */

@media (max-width: 700px) {
  body { padding: 8px 10px 10px; }
  /* The page list covers the cards instead of squeezing them. */
  .page-list {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(80vw, 260px);
    max-height: none;
    padding: 12px 10px;
    background: var(--bg);
    box-shadow: var(--shadow-run);
  }
  .tasks { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
  .total-time { font-size: 1.25rem; }
}

/* ---------- common header / settings pieces (same in every app) ---------- */

#fullscreen-btn[hidden] { display: none; }
.fs-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#fullscreen-btn .fs-exit,
#fullscreen-btn.is-fullscreen .fs-enter { display: none; }
#fullscreen-btn.is-fullscreen .fs-exit { display: block; }

/* The version next to the app name opens the changelog. */
#appVersion { cursor: pointer; }
#appVersion:hover { text-decoration: underline; }

/* A link styled as a button (「アプリ一覧を開く」). */
a.btn { text-decoration: none; display: inline-block; }

#feedbackSend { background: var(--accent); border-color: var(--accent); color: #fff; }
#feedbackSend:disabled { opacity: .6; }

/* Quick tooltip for icon buttons (mouse only; shown by initQuickTips after 0.5 s). */
.quick-tip {
  position: fixed;
  z-index: 100;
  max-width: 260px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: .8rem;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.quick-tip[hidden] { display: none; }
