/* ====== デザイントークン(モック踏襲) ====== */
:root {
  --bg: #2B3947;
  --card: #34434F;
  --card-deep: #2F3D49;
  --text: #F7F5F1;
  --text-dim: rgba(247, 245, 241, 0.62);
  --accent: #C9A96B;
  --accent-dim: rgba(201, 169, 107, 0.35);
  --line: rgba(247, 245, 241, 0.12);
  --danger: #D98880;
  --mincho: "Zen Old Mincho", "Hiragino Mincho ProN", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --tabbar-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ====== ヘッダー ====== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.app-name {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--accent);
}
.practice-name {
  margin: 2px 0 0;
  font-family: var(--mincho);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 62vw;
}

/* ====== レイアウト ====== */
main {
  padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  max-width: 560px;
  margin: 0 auto;
}
.hidden { display: none !important; }

/* ====== ボタン ====== */
.btn {
  font-family: var(--sans);
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  padding: 9px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: 0.75; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #26313C;
  font-weight: 700;
}
.btn-ghost {
  background: transparent;
  border-color: var(--accent-dim);
  color: var(--accent);
}
.btn-danger {
  background: transparent;
  border-color: rgba(217, 136, 128, 0.4);
  color: var(--danger);
}
.btn-block { display: block; width: 100%; padding: 13px; font-size: 15px; }
.btn-sm { font-size: 12px; padding: 6px 10px; border-radius: 8px; }

/* ====== フォーム ====== */
.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 0.06em;
}
input[type="text"], input[type="number"], textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 16px; /* iOSズーム防止のため16px以上 */
  color: var(--text);
  background: var(--card-deep);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 64px; }
input::placeholder, textarea::placeholder { color: rgba(247, 245, 241, 0.3); }

/* チップ */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-deep);
  color: var(--text-dim);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #26313C;
  font-weight: 700;
}

/* ====== セクション見出し ====== */
.section-title {
  font-family: var(--mincho);
  font-size: 20px;
  font-weight: 600;
  margin: 4px 0 4px;
}
.section-lead {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 16px;
}

/* ====== ① 分解シート ====== */
.cut-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px 12px;
  margin-bottom: 14px;
}
.cut-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cut-no {
  font-family: var(--mincho);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
}
.cut-actions { display: flex; gap: 6px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-sec { max-width: 110px; }

/* 画像添付 */
.img-attach { margin-top: 2px; }
.img-attach input[type="file"] { display: none; }
.img-preview-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.img-preview {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--accent-dim);
  cursor: pointer;
  background: var(--card-deep);
}
.img-btns { display: flex; flex-direction: column; gap: 6px; }

/* ====== ② 撮影カンペ ====== */
.cue-warning {
  font-family: var(--mincho);
  text-align: center;
  font-size: 13px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 16px;
  letter-spacing: 0.05em;
}
.cue-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 20px 24px;
  text-align: center;
}
.cue-counter {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  margin: 0 0 8px;
}
.cue-sec {
  font-family: var(--mincho);
  font-size: 56px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  margin: 0;
}
.cue-sec small {
  font-size: 20px;
  font-weight: 400;
  margin-left: 2px;
}
.cue-camera {
  display: inline-block;
  font-family: var(--mincho);
  font-size: 15px;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 16px;
  margin: 10px 0 18px;
  letter-spacing: 0.1em;
}
.cue-action {
  font-family: var(--mincho);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.5;
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}
.cue-memo {
  font-size: 14px;
  color: var(--text-dim);
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}
.cue-telop {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}
.cue-telop-label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  margin: 0 0 4px;
}
.cue-telop-text {
  font-family: var(--mincho);
  font-size: 18px;
  margin: 0;
  overflow-wrap: anywhere;
}
.cue-telop-in {
  display: inline-block;
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
}
.cue-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 12px;
  border: 1px solid var(--accent-dim);
  margin-top: 16px;
  cursor: pointer;
}
.cue-nav {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.cue-nav .btn { flex: 1; padding: 14px; font-size: 15px; }
.cue-nav .btn:disabled { opacity: 0.35; cursor: default; }

/* ====== ③ 差分チェック ====== */
.diff-q {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}
.diff-q-label {
  font-family: var(--mincho);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
}
.log-list { list-style: none; margin: 8px 0 0; padding: 0; }
.log-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 13px;
}
.log-date { color: var(--text-dim); font-size: 11px; margin: 0 0 6px; letter-spacing: 0.08em; }
.log-answers { margin: 0 0 6px; color: var(--text-dim); }
.log-answers strong { color: var(--text); font-weight: 600; }
.log-fix {
  margin: 0;
  font-family: var(--mincho);
  color: var(--accent);
  overflow-wrap: anywhere;
}
.log-fix::before { content: "直す → "; font-size: 11px; color: var(--text-dim); font-family: var(--sans); }

.export-block {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.export-note { font-size: 12px; color: var(--text-dim); margin: 8px 0 0; }

/* ====== 練習一覧モーダル ====== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 27, 34, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-sheet {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 78vh;
  overflow-y: auto;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-title {
  font-family: var(--mincho);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.practice-list { list-style: none; margin: 0 0 14px; padding: 0; }
.practice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.practice-item.current { border-color: var(--accent); }
.practice-item-main { flex: 1; min-width: 0; cursor: pointer; }
.practice-item-name {
  font-family: var(--mincho);
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.practice-item-meta { font-size: 11px; color: var(--text-dim); margin: 2px 0 0; }
.practice-empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 20px 0; }

/* ====== 画像拡大 ====== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 26, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 8px;
}

/* ====== 空状態 ====== */
.empty-state { text-align: center; padding: 56px 12px; }
.empty-title { font-family: var(--mincho); font-size: 20px; margin: 0 0 8px; }
.empty-sub { color: var(--text-dim); font-size: 14px; margin: 0 0 22px; }

/* ====== 下部タブ ====== */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(38, 49, 60, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.tab {
  flex: 1;
  height: var(--tabbar-h);
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--mincho);
  font-size: 14px;
  letter-spacing: 0.08em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
}
.tab .tab-num { font-size: 12px; }
.tab.active {
  color: var(--accent);
  font-weight: 700;
}
