:root {
  color-scheme: light;
  --bg: #fff8f2;
  --card-bg: #ffffff;
  --accent: #ff9533;
  --accent-dark: #e97e12;
  --text: #33291f;
  --text-sub: #7a6e60;
  --border: #f0e2d3;
  --success: #2f9e5c;
  --error: #d64545;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.6;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ヘッダー */
.app-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header__inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header__title {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
}
.app-header__version {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-sub);
}
.app-header__help {
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 10px;
  min-height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 10px;
}
.app-header__help:hover,
.app-header__help:focus-visible {
  background: var(--bg);
}

/* メイン */
.app-main {
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.screen { width: 100%; }

.lead {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 6px;
}
.sub {
  font-size: 14px;
  color: var(--text-sub);
  margin: 0 0 20px;
}
.privacy-note {
  font-size: 12px;
  color: var(--text-sub);
  text-align: center;
  margin-top: 18px;
}

/* 主役ボタン */
.primary-button {
  display: block;
  width: 100%;
  min-height: 52px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  padding: 14px 20px;
  text-align: center;
  transition: background .15s ease, transform .05s ease;
}
.primary-button:hover { background: var(--accent-dark); }
.primary-button:active { transform: scale(0.98); }
.primary-button:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 2px;
}
.primary-button:disabled {
  background: #e5c9a8;
  cursor: not-allowed;
}

.picker-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  padding: 14px 20px;
  text-align: center;
  transition: background .15s ease, transform .05s ease;
}
.picker-button:hover { background: var(--accent-dark); }
.picker-button:active { transform: scale(0.98); }
.picker-button:has(+ input:focus-visible) {
  outline: 3px solid var(--accent-dark);
  outline-offset: 2px;
}

.text-button {
  display: block;
  width: 100%;
  min-height: 40px;
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
  margin-top: 14px;
  padding: 8px;
}
.text-button:hover { color: var(--text); }
.text-button:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 失敗時の技術的な詳細（開発者向け・折りたたみ表示） */
.error-detail {
  margin-top: 20px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-sub);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: text;
  -webkit-user-select: text;
}

/* 選択済みファイルカード */
.file-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.file-card__icon { font-size: 32px; }
.file-card__info { min-width: 0; }
.file-card__name {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-card__meta {
  margin: 0;
  font-size: 13px;
  color: var(--text-sub);
}

/* 進捗 */
.progress-wrap { margin: 40px 0 8px; }
.progress-bar {
  width: 100%;
  height: 14px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
  background-image: linear-gradient(
    90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,.35) 50%,
    rgba(255,255,255,0) 100%
  );
  background-size: 60px 100%;
  background-repeat: no-repeat;
  animation: progress-shimmer 1.4s linear infinite;
}
@keyframes progress-shimmer {
  0% { background-position: -60px 0; }
  100% { background-position: calc(100% + 60px) 0; }
}
.progress-label {
  text-align: center;
  font-size: 14px;
  color: var(--text-sub);
  margin: 10px 0 0;
}
.progress-elapsed {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  margin: 4px 0 0;
}

/* 結果リスト */
.segment-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.segment-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.segment-item__row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.segment-item__badge {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.segment-item__info { flex: 1; min-width: 0; }
.segment-item__range {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.segment-item__dur {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-sub);
}
.segment-item__save {
  flex: none;
  min-height: 40px;
  min-width: 76px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.segment-item__save:hover { background: var(--accent-dark); }
.segment-item__save:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 2px;
}
.segment-item__save[data-saved="true"] {
  background: var(--success);
}
.segment-item__preview {
  display: block;
  width: 100%;
  max-height: 220px;
  margin-top: 12px;
  border-radius: 12px;
  background: #000;
}
.segment-item__hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-sub);
  text-align: center;
}

/* トースト */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
  z-index: 100;
}
.toast[data-type="error"] {
  background: var(--error);
  border-radius: var(--radius);
  text-align: left;
}
.toast[data-type="caution"] {
  background: #b8860b;
  border-radius: var(--radius);
  text-align: left;
}

@media (max-width: 360px) {
  .app-main { padding: 24px 14px 50px; }
}
