/* こえスタジオ：見た目。文字はすべてゴシック体。 */
:root {
  --bg: #F6F4EF;
  --card: #FFFFFF;
  --ink: #1F1D1A;
  --sub: #6B665E;
  --line: #E4DFD6;
  --soft: #EFEBE3;
  --accent: #D9481F;
  --accent-ink: #FFFFFF;
  --accent-soft: #FBE9E2;
  --rec: #D7263D;
  --ok: #23785A;
  --warn: #9A6400;
  --wave: #3C3833;
  --wave-dim: #C9C2B6;
  --cut: #EFE9DF;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 6px 20px rgba(40, 30, 20, .06);
  --r: 16px;
  --tabs-h: 62px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --card: #211F1C;
    --ink: #F1EEE8;
    --sub: #A8A196;
    --line: #37332E;
    --soft: #2A2723;
    --accent: #FF7A50;
    --accent-ink: #1B120E;
    --accent-soft: #3A221A;
    --rec: #FF5468;
    --ok: #58C79E;
    --warn: #E5B454;
    --wave: #E6E0D6;
    --wave-dim: #5B564E;
    --cut: #2B2824;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
p { margin: 0 0 10px; }
h1 { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { height: 100%; }
.view { height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }
.loading { padding: 80px 24px; text-align: center; color: var(--sub); }

/* 上の帯 */
.topbar {
  flex: none; display: flex; align-items: center; gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
  background: var(--bg);
}
.home-top { padding-left: 16px; gap: 10px; }
.home-top h1 { font-size: 19px; font-weight: 700; letter-spacing: .02em; }
.logo { width: 30px; height: 30px; border-radius: 8px; }
.title-input {
  flex: 1; min-width: 0; height: 44px; border: 0; background: transparent;
  font-size: 18px; font-weight: 700; padding: 0 6px; border-radius: 10px;
}
.title-input:focus { background: var(--card); outline: 2px solid var(--accent); }
.title-input::placeholder { color: var(--sub); font-weight: 500; }

.scroll { flex: 1; overflow-y: auto; padding: 4px 14px 28px; -webkit-overflow-scrolling: touch; }
.home-scroll { padding-bottom: 28px; }

/* ボタン */
.icon-btn {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 12px; color: var(--ink);
}
.icon-btn:active:not(:disabled) { background: var(--soft); }
.icon-btn.sm { width: 38px; height: 38px; color: var(--sub); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 700; font-size: 15px; text-decoration: none; text-align: center; line-height: 1.3;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.danger { background: transparent; border-color: var(--line); color: var(--rec); }
.btn.wide { display: flex; width: 100%; margin-top: 10px; }
.btn.sm { min-height: 40px; min-width: 48px; padding: 0 12px; }
.btn:active:not(:disabled) { transform: translateY(1px); filter: brightness(.96); }
.btn svg { width: 20px; height: 20px; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 120px; }

/* カードと見出し */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.card-label { font-size: 12px; font-weight: 700; color: var(--sub); letter-spacing: .06em; margin-bottom: 8px; }
.sec-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 700; color: var(--sub); letter-spacing: .06em; margin: 22px 4px 8px; }
.sec-sub { font-weight: 500; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.hint { font-size: 13px; color: var(--sub); margin: 0; line-height: 1.6; }
.hint.pad { padding: 8px 4px; }
.hint.sub { display: block; font-weight: 400; }
.hint.center { text-align: center; margin-top: 22px; }
.field {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px;
  padding: 12px; font-size: 16px; line-height: 1.6; resize: vertical;
}
.field:focus { outline: 2px solid var(--accent); border-color: transparent; }
.form-label { display: block; font-size: 12px; font-weight: 700; color: var(--sub); margin: 14px 2px 6px; letter-spacing: .06em; }
.desc-input { background: var(--bg); }

/* 一覧（収録・素材） */
.new-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 20px; padding: 16px 18px; margin-top: 6px;
  box-shadow: var(--shadow);
}
.new-btn b { display: block; font-size: 17px; }
.new-sub { display: block; font-size: 13px; opacity: .9; }
.new-icon { width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, .22); display: grid; place-items: center; flex: none; }
.new-btn:active { transform: translateY(1px); }
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 8px 10px 14px; min-height: 64px; cursor: default;
}
.row[role=button] { cursor: pointer; }
.row[role=button]:active { background: var(--soft); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--sub); font-variant-numeric: tabular-nums; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chev { color: var(--sub); transform: rotate(-90deg); display: grid; }
.play-mini { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--soft); color: var(--ink); display: grid; place-items: center; }
.empty { text-align: center; color: var(--sub); padding: 34px 16px; }
.empty.small { padding: 18px 12px; font-size: 13px; background: transparent; border: 1px dashed var(--line); border-radius: 14px; }
.empty p { margin: 0; }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; margin: 0 auto 10px; color: var(--sub); }
.empty-sub { font-size: 13px; margin-top: 4px !important; }
.login-row { display: flex; gap: 8px; margin-top: 10px; }
.login-row .field { flex: 1; min-width: 0; }

/* 下のタブ */
.tabs {
  flex: none; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; height: var(--tabs-h); border: 0; background: transparent; color: var(--sub); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 700; }
.tab.on { color: var(--accent); }

/* 切り替え */
.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; gap: 3px; margin: 8px 0; }
.seg-btn { flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--sub); }
.seg-btn.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.row-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.row-inline .seg { width: 170px; margin: 0; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row b { font-weight: 600; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 32px; border-radius: 16px; background: var(--line); position: relative; margin: 0; transition: background .15s; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }

/* ブロック */
.blocks { display: flex; flex-direction: column; gap: 10px; }
.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.block.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.block-head { display: flex; align-items: center; gap: 8px; padding: 6px 4px 2px 12px; cursor: pointer; }
.num { flex: none; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--soft); color: var(--sub); font-size: 12px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.block.sel .num { background: var(--accent); color: var(--accent-ink); }
.name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dur { font-size: 13px; color: var(--sub); font-variant-numeric: tabular-nums; }
.wave-wrap { position: relative; margin: 0 12px 10px; height: 56px; cursor: pointer; }
.wave { width: 100%; height: 56px; display: block; }
.playhead { display: none; position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--accent); border-radius: 1px; pointer-events: none; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 10px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--soft); color: var(--sub); white-space: nowrap; }
.badge.live { background: var(--accent-soft); color: var(--accent); }
.badge.warn { color: var(--warn); }
.acts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.act { min-height: 48px; border: 0; background: var(--card); font-weight: 600; font-size: 14px; }
.act:active { background: var(--soft); }
.act.danger { color: var(--rec); }
@media (min-width: 520px) { .acts { grid-template-columns: repeat(5, 1fr); } }

.add-card { margin-top: 12px; }
.add-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.add-btn { min-height: 76px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 700; font-size: 13px; }
.add-btn.rec { background: var(--rec); border-color: transparent; color: #fff; }
.add-btn:active { transform: translateY(1px); }

.bgm-head { display: flex; align-items: center; gap: 10px; padding-bottom: 6px; }
.bgm-name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* つまみ */
.slider { display: block; padding: 8px 0 2px; }
.slider-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.val { color: var(--sub); font-variant-numeric: tabular-nums; font-weight: 500; }
input[type=range] { width: 100%; height: 36px; margin: 0; accent-color: var(--accent); }

/* 再生の帯 */
.transport {
  flex: none; background: var(--card); border-top: 1px solid var(--line);
  padding: 2px 12px calc(8px + env(safe-area-inset-bottom));
}
.transport-row { display: flex; align-items: center; gap: 8px; }
.play-btn { flex: none; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; }
.play-btn svg { width: 26px; height: 26px; }
.play-btn:active { transform: scale(.96); }
.time { flex: 1; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 700; white-space: nowrap; }
.time-sep { color: var(--sub); margin: 0 5px; font-weight: 400; }
#t-total { color: var(--sub); font-weight: 500; }
.rec-btn { flex: none; min-height: 48px; padding: 0 16px; border-radius: 24px; border: 0; background: var(--rec); color: #fff; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; }

/* シート */
.sheet-wrap { position: fixed; inset: 0; background: rgba(20, 16, 12, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .18s ease-out; }
.sheet-wrap.out { opacity: 0; transition: opacity .2s; }
.sheet { width: 100%; max-width: 640px; max-height: 92dvh; background: var(--card); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: rise .22s ease-out; }
.sheet-wrap.full .sheet { height: 92dvh; }
.sheet-head { flex: none; display: flex; align-items: center; padding: 10px 8px 4px 18px; min-height: 52px; }
.sheet-title { flex: 1; min-width: 0; font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 18px calc(22px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.sheet-msg { font-size: 14px; color: var(--sub); }
.sheet-msg.ok { color: var(--ok); font-weight: 700; }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

.pick-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.pick { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); text-align: left; }
.pick:active { background: var(--soft); }
.pick-icon { flex: none; color: var(--sub); display: grid; }
.pick-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-dur { color: var(--sub); font-size: 13px; font-variant-numeric: tabular-nums; }

.summary { background: var(--bg); border-radius: 12px; padding: 12px; margin-top: 8px; }
.summary-main { font-weight: 700; }
.summary-sub { font-size: 13px; color: var(--sub); font-variant-numeric: tabular-nums; }

/* 録音 */
.rec-box { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 14px; }
.rec-state { font-weight: 700; color: var(--sub); min-height: 1.6em; display: flex; align-items: center; gap: 8px; }
.rec-state.on { color: var(--rec); }
.rec-state.on::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-size: 54px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; line-height: 1.1; }
.rec-wave { width: 100%; height: 120px; background: var(--bg); border-radius: 14px; }
.meter { width: 100%; height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--ok); border-radius: 4px; transition: width .08s linear; }
.meter.hot .meter-fill { background: var(--rec); }
.rec-buttons { display: flex; gap: 10px; width: 100%; margin-top: 10px; }
.rec-buttons .btn { flex: 1; padding: 0 8px; }
.rec-done { background: var(--rec); color: #fff; flex: 1.4 !important; }

/* こまかく編集 */
.trim-info { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; font-weight: 700; margin: 6px 0; }
.trim-len { color: var(--accent); }
.trim-scroll { overflow-x: auto; overflow-y: hidden; background: var(--bg); border-radius: 14px; padding: 18px 16px 26px; touch-action: pan-x; }
.trim-inner { position: relative; height: 140px; min-width: 100%; }
.trim-canvas { position: absolute; inset: 0; width: 100%; height: 140px; display: block; }
.trim-sel { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 16%, transparent); pointer-events: none; border-radius: 2px; }
.trim-handle { position: absolute; top: -12px; bottom: -22px; width: 40px; margin-left: -20px; touch-action: none; cursor: ew-resize; z-index: 2; }
.trim-handle::before { content: ""; position: absolute; left: 19px; top: 8px; bottom: 16px; width: 3px; background: var(--accent); border-radius: 2px; }
.knob { position: absolute; left: 6px; bottom: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); border: 3px solid var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.trim-handle.z .knob { bottom: auto; top: -4px; }
.trim-cursor { display: none; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); pointer-events: none; }
.zoom-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.trim-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.trim-acts .btn { padding: 0 10px; font-size: 14px; }
.trim-acts .btn.primary { grid-column: 1 / -1; }

/* 進み具合 */
.progress-box { padding: 16px 0 8px; }
.progress-text { font-weight: 700; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.progress { height: 10px; background: var(--soft); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 5px; transition: width .2s; }

.share-box { margin-top: 4px; }
.share-url { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; margin-top: 4px; }
.audio { width: 100%; margin: 6px 0 4px; }

/* お知らせ */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 80; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; max-width: 480px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); animation: rise .2s ease-out; }
.toast.out { opacity: 0; transition: opacity .25s; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.error { background: var(--rec); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
