/* Weekly presentation pacing trainer - mobile first. */
:root {
  --navy: #0b2a5b;
  --navy-soft: #16447f;
  --red: #c8102e;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #17202e;
  --muted: #6b7280;
  --line: #dfe4ec;
  --ok: #1c8a4a;
  --warn: #b7791f;
  --ng: #c8102e;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 0 48px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

.hero {
  background: linear-gradient(135deg, var(--navy), var(--navy-soft));
  color: #fff;
  padding: 26px 18px 22px;
  padding-top: calc(26px + env(safe-area-inset-top));
}
.hero h1 { margin: 0 0 6px; font-size: 20px; line-height: 1.4; }
.hero p { margin: 0; font-size: 13px; opacity: .85; line-height: 1.6; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.step {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* --- seconds --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label {
  position: relative;
  flex: 0 0 auto;
}
.chips input { position: absolute; opacity: 0; width: 0; height: 0; }
.chips span {
  display: block;
  min-width: 56px;
  padding: 9px 10px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: .12s;
}
.chips input:checked + span {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 700;
}
.chips input:focus-visible + span { outline: 2px solid var(--navy); outline-offset: 2px; }

.target { margin: 12px 0 0; font-size: 14px; }
.target b { font-size: 18px; color: var(--navy); }

.pace { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
.pace + .status { margin-top: 6px; }
.pace label { font-size: 13px; color: var(--muted); }
.pace select {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%236b7280' d='M0 0h10L5 6z'/%3E%3C/svg%3E") no-repeat right 10px center/9px 6px;
  color: inherit;
  font: 700 15px/1 inherit;
  padding: 9px 30px 9px 12px;
  font-variant-numeric: tabular-nums;
}
.pace select:focus { outline: 2px solid var(--navy); outline-offset: 1px; }
.pace .sub { color: var(--muted); font-size: 12px; }

/* --- script blocks --- */
.block { margin: 0 0 16px; }
.block label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.num { color: var(--red); font-size: 15px; }

textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: inherit;
  font: inherit;
  line-height: 1.8;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--navy); outline-offset: -1px; background: #fff; }

.count { margin-top: 4px; text-align: right; font-size: 12px; color: var(--muted); }
.count b { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink); }

.total { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.total p { margin: 8px 0 0; font-size: 14px; }
.total b { font-size: 22px; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 999px; background: #e8ecf3; overflow: hidden; }
.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--ok);
  transition: width .2s, background .2s;
}
.diff { font-size: 13px; font-weight: 700; margin-left: 4px; }
.total.is-ok    .diff { color: var(--ok); }
.total.is-warn  .diff { color: var(--warn); }
.total.is-warn  .bar i { background: var(--warn); }
.total.is-over  .diff { color: var(--ng); }
.total.is-over  .bar i { background: var(--ng); }

.dict { margin-top: 10px; }
.dictbar {
  height: 6px;
  border-radius: 999px;
  background: #e8ecf3;
  overflow: hidden;
  margin-bottom: 6px;
}
.dictbar[hidden] { display: none; }
.dictbar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--navy);
  transition: width .2s linear;
}
.dictbar i.indeterminate {
  width: 40%;
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.status { margin: 10px 0 0; font-size: 12px; color: var(--muted); min-height: 1.4em; }
.status.err { color: var(--ng); }
.note { margin: 0 0 12px; font-size: 13px; color: var(--muted); }

/* --- drafts --- */
.card h2.plain { font-size: 15px; }
.saverow { display: flex; gap: 8px; }
.saverow input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: inherit;
  font: inherit;
}
.saverow input:focus { outline: 2px solid var(--navy); outline-offset: -1px; }

.drafts { list-style: none; margin: 14px 0 0; padding: 0; }
.drafts li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.drafts .meta { flex: 1; min-width: 0; }
.drafts .dname {
  display: block;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drafts .dsub { display: block; font-size: 11px; color: var(--muted); }
.drafts button {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 8px;
  padding: 7px 12px;
  font: 700 12px/1 inherit;
  cursor: pointer;
}
.drafts button.del { color: var(--ng); }

/* --- buttons --- */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--navy);
  border-radius: 12px;
  background: #fff;
  color: var(--navy);
  font: 700 16px/1.2 inherit;
  cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.stop { background: var(--red); border-color: var(--red); color: #fff; }
.btn.slim { width: auto; flex: 0 0 auto; padding: 11px 22px; font-size: 14px; }

.playclock {
  margin-top: 12px;
  text-align: center;
  line-height: 1.1;
  color: var(--navy);
}
.playclock b {
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.playclock .unit { font-size: 13px; margin-left: 3px; }
.playclock.over { color: var(--ng); }

.playbar { height: 6px; border-radius: 999px; background: #e8ecf3; overflow: hidden; margin-top: 12px; }
.playbar i { display: block; height: 100%; width: 0; background: var(--navy); }
.playbar i.over { background: var(--ng); }

/* --- practice overlay --- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.overlay[hidden] { display: none; }
.overlay.alarm { background: var(--red); }
.overlay.done  { background: #111827; }

.ovbar { display: flex; align-items: center; justify-content: space-between; font-size: 13px; opacity: .9; }
.close {
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,.15);
  border: 0;
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
}
.clock {
  text-align: center;
  font-size: clamp(76px, 30vw, 150px);
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 4px;
}
.ovscript {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.ovline { margin: 0 0 12px; font-size: 17px; line-height: 1.9; white-space: pre-wrap; }
.ovline:last-child { margin-bottom: 0; }
.ovline:empty { display: none; }
.overlay .btn { border-color: #fff; background: #fff; color: var(--navy); }
.overlay .btn.stop { background: rgba(0,0,0,.3); border-color: rgba(255,255,255,.6); color: #fff; }

@media (prefers-color-scheme: dark) {
  .playclock { color: #93b4e8; }
  :root {
    --bg: #11151c;
    --card: #1a202a;
    --ink: #e8eaf0;
    --muted: #97a1b2;
    --line: #2b3444;
  }
  textarea { background: #151a23; }
  textarea:focus { background: #151a23; }
  .chips span, .saverow input, .drafts button { background: #151a23; }
  .pace select { background-color: #151a23; }
  .bar, .playbar, .dictbar { background: #2b3444; }
}

/* --- language picker --- */
.hero { position: relative; }
.langrow {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin: -6px 0 10px;
}
.langicon { font-size: 15px; line-height: 1; }
.langrow select {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 8px;
  background: rgba(255,255,255,.12) url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%23ffffff' d='M0 0h10L5 6z'/%3E%3C/svg%3E") no-repeat right 9px center/9px 6px;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 7px 26px 7px 10px;
  max-width: 100%;
}
.langrow select option { color: #17202e; background: #fff; }
.langrow select:focus { outline: 2px solid #fff; outline-offset: 1px; }
