:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --label: #000000;
  --label2: rgba(60, 60, 67, 0.62);
  --label3: rgba(60, 60, 67, 0.34);
  --sep: rgba(60, 60, 67, 0.16);
  --fill: rgba(120, 120, 128, 0.12);
  --fill2: rgba(120, 120, 128, 0.2);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --apple: #fa2d48;
  --spotify: #1db954;
  --accent: var(--blue);
  --material: rgba(249, 249, 249, 0.78);
  --radius: 14px;
  --gutter: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --label: #ffffff;
    --label2: rgba(235, 235, 245, 0.62);
    --label3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.6);
    --fill: rgba(118, 118, 128, 0.24);
    --fill2: rgba(118, 118, 128, 0.36);
    --blue: #0a84ff;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --material: rgba(29, 29, 31, 0.72);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 17px/1.42 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.card { background: var(--card); border-radius: var(--radius); }

/* ---------- ホーム ---------- */
.screen-home {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: max(56px, calc(env(safe-area-inset-top) + 40px));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.hero { text-align: center; margin-bottom: 28px; }
.logo {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}
.hero h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.h1-svc {
  display: block;
  margin-bottom: 4px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--label2);
}
.lead { margin: 8px 0 0; color: var(--label2); font-size: 17px; line-height: 1.45; }

.input-card { padding: 14px; }
.field { position: relative; }
.field textarea {
  display: block;
  width: 100%;
  min-height: 76px;
  resize: none;
  border: 0;
  outline: none;
  background: var(--fill);
  border-radius: 10px;
  padding: 12px 40px 12px 14px;
  font-size: 16px;
  line-height: 1.4;
  word-break: break-all;
  transition: box-shadow 0.15s ease;
}
.field textarea::placeholder { color: var(--label3); }
.field textarea:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 55%, transparent); }
.clear { position: absolute; top: 12px; right: 12px; color: var(--label3); width: 22px; height: 22px; display: grid; place-items: center; }

.route {
  display: flex; align-items: center; gap: 8px;
  min-height: 22px;
  margin: 10px 2px 0;
  font-size: 13px; font-weight: 600; color: var(--label2);
}
.route:empty { margin-top: 0; min-height: 0; }
.svc { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.svc i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex: none; }
.svc.apple i { background: linear-gradient(135deg, #ff5e6c, #fa2d48); }
.svc.spotify i { background: linear-gradient(135deg, #3be47a, #1db954); border-radius: 50%; }
.route .arrow { color: var(--label3); }
.route.bad { color: var(--red); font-weight: 500; }

.actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 50px; padding: 0 18px;
  border-radius: 12px;
  font-size: 17px; font-weight: 600;
  transition: transform 0.1s ease-out, opacity 0.15s ease, background-color 0.15s ease;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-filled { background: var(--accent); color: #fff; }
.btn-filled:disabled { background: var(--fill2); color: var(--label3); transform: none; opacity: 1; cursor: default; }
.btn-tinted { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.btn-large { width: 100%; height: 54px; border-radius: 14px; }
.error { margin: 12px 2px 0; color: var(--red); font-size: 15px; line-height: 1.45; }

.steps { list-style: none; padding: 0; margin: 28px 4px 0; display: grid; gap: 14px; }
.steps li { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--label2); }
.steps b { color: var(--label); font-weight: 600; }
.num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--fill); color: var(--label2);
  font-size: 14px; font-weight: 700;
}
.fineprint { word-break: auto-phrase; margin: 0 4px; padding-top: 20px; font-size: 12px; line-height: 1.6; color: var(--label3); text-align: center; }

/* ---------- 結果 ---------- */
.screen-result { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: calc(44px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  margin: 0 calc(-1 * var(--gutter));
  padding-left: 8px; padding-right: 8px;
  background: transparent;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
.topbar.scrolled {
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--sep);
}
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); font-size: 17px; height: 44px; padding: 0 8px; justify-self: start; }
.back:active, .share-top:active { opacity: 0.4; }
.topbar-title { font-size: 17px; font-weight: 600; opacity: 0; transition: opacity 0.2s ease; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar.scrolled .topbar-title { opacity: 1; }
.share-top { justify-self: end; color: var(--blue); width: 44px; height: 44px; display: grid; place-items: center; }

.source { display: flex; gap: 16px; align-items: center; padding: 12px 0 20px; }
.cover {
  flex: none; width: 112px; height: 112px; border-radius: 10px;
  background: var(--fill) center/cover no-repeat;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}
.source-meta { min-width: 0; }
.route-small { margin: 0 0 6px; font-size: 12px; }
.source h2 {
  margin: 0; font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  word-break: break-word;
}
.source p { margin: 4px 0 0; color: var(--label2); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.summary { padding: 14px 16px; margin-bottom: 12px; }
.progress-label { display: flex; justify-content: space-between; font-size: 15px; color: var(--label2); margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 3px; background: var(--accent); transition: width 0.3s ease; }
.tally { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.tally .big { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tally .of { color: var(--label2); font-size: 15px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 11px; border-radius: 15px;
  background: var(--fill); font-size: 13px; font-weight: 600; color: var(--label2);
  font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] { background: var(--label); color: var(--card); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.ok { background: var(--green); }
.dot.close { background: var(--orange); }
.dot.none { background: var(--label3); }
.notice { margin: 12px 0 0; font-size: 13px; line-height: 1.55; color: var(--label2); }

.tracks { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.track { position: relative; }
.track + .track::before { content: ""; position: absolute; top: 0; left: 72px; right: 0; height: 0.5px; background: var(--sep); }
.track > a, .track > div {
  display: flex; align-items: center; gap: 12px;
  min-height: 68px; padding: 8px 14px 8px 12px;
  transition: background-color 0.12s ease;
}
.track > a:active { background: var(--fill); }
.art {
  flex: none; width: 48px; height: 48px; border-radius: 6px;
  background: var(--fill) center/cover no-repeat;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}
.art.empty { display: grid; place-items: center; color: var(--label3); }
.meta { flex: 1; min-width: 0; }
.t1, .t2, .t3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t1 { font-size: 16px; line-height: 1.3; }
.t2 { font-size: 13px; line-height: 1.35; color: var(--label2); margin-top: 1px; }
.t3 { font-size: 12px; line-height: 1.35; color: var(--orange); margin-top: 2px; }
.track[data-s="none"] .t1 { color: var(--label2); }
.state { flex: none; display: grid; place-items: center; width: 28px; height: 28px; }
.state.pending .spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--fill2); border-top-color: var(--label3);
  animation: spin 0.8s linear infinite;
}
.state-pill {
  flex: none; height: 28px; padding: 0 12px; border-radius: 14px;
  display: inline-flex; align-items: center; font-size: 13px; font-weight: 600;
  background: var(--fill); color: var(--blue);
}
.track.just { animation: pop 0.35s ease-out; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { background: color-mix(in srgb, var(--green) 10%, transparent); } to { background: transparent; } }

.spacer { height: 12px; }

.dev { margin-top: 32px; padding: 16px; }
.dev-result { margin-top: 24px; }
.dev-label { margin: 0; font-size: 12px; font-weight: 600; color: var(--label3); letter-spacing: 0.02em; }
.dev-name { margin: 2px 0 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.dev-bio { margin: 6px 0 0; font-size: 14px; line-height: 1.6; color: var(--label2); word-break: auto-phrase; text-wrap: pretty; }
.dev-links { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.dev-links a {
  display: inline-flex; align-items: center; height: 32px; padding: 0 13px; border-radius: 16px;
  background: var(--fill); color: var(--blue); font-size: 14px; font-weight: 600;
  transition: transform 0.1s ease-out, opacity 0.15s ease;
}
.dev-links a:active { transform: scale(0.96); opacity: 0.7; }
.credit { text-align: center; font-size: 12px; color: var(--label3); margin: 16px 0 0; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px max(var(--gutter), env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -0.5px 0 var(--sep);
  animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.dock > * { max-width: 448px; margin-left: auto; margin-right: auto; }
.dock-hint { margin-top: 8px; margin-bottom: 0; font-size: 12px; line-height: 1.5; color: var(--label2); text-align: center; }
.dock-hint:empty { display: none; }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); z-index: 50;
  transform: translate(-50%, -140%);
  padding: 11px 18px; border-radius: 22px;
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18), 0 0 0 0.5px var(--sep);
  font-size: 15px; font-weight: 600; white-space: nowrap;
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.15);
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }

.screen { animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (min-width: 640px) {
  .screen-home { padding-top: 12vh; min-height: auto; }
  .fineprint { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar.scrolled, .dock, .toast { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
