/* ============================================================
   TSUKUYOMI Studio — 占いSNS運用スタジオ
   Design System 「深夜の鑑定室」
   墨紺 × シャンパンゴールド × 月光シルバー / 明朝ディスプレイ
   ============================================================ */

:root {
  /* --- 色 --- */
  --ink-0: #0b0912;            /* 最深部・ページ地 */
  --ink-1: #120f1c;            /* 面 */
  --ink-2: #191527;            /* カード */
  --ink-3: #221c33;            /* ホバー面・入力地 */
  --ink-4: #2c2542;            /* 境界強 */
  --gold: #d9b36c;             /* シャンパンゴールド主 */
  --gold-bright: #f0d9a0;      /* 金・高輝度 */
  --gold-deep: #a97f3c;        /* 金・深 */
  --gold-line: rgba(217, 179, 108, .22);
  --gold-line-strong: rgba(217, 179, 108, .45);
  --wisteria: #a493e6;         /* 藤紫（副アクセント） */
  --wisteria-dim: #6f61a8;
  --moon: #ece9f4;             /* 月光（主文字色） */
  --moon-dim: #b7b1c9;         /* 副文字 */
  --moon-faint: #837c99;       /* 三次文字 */
  --jade: #7fd3b2;             /* 成功 */
  --ember: #e08585;            /* 警告・削除 */
  --amber: #e5b567;            /* 注意 */

  /* --- 字 --- */
  --font-display: "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --font-body: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic Medium", "Yu Gothic", "Noto Sans JP", sans-serif;

  /* --- 寸 --- */
  --sidebar-w: 236px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 8px 28px rgba(0, 0, 0, .38);
  --shadow-pop: 0 18px 60px rgba(0, 0, 0, .55);

  /* --- 動 --- */
  --ease: cubic-bezier(.22, .8, .3, 1);
}

/* ============ リセット・基礎 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--ink-0);
  color: var(--moon);
  font-size: 14px;
  line-height: 1.75;
  letter-spacing: .02em;
  overflow: hidden;
  height: 100vh;
}
::selection { background: rgba(217, 179, 108, .35); color: #fff; }

/* スクロールバー */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ink-4); border-radius: 99px;
  border: 2px solid var(--ink-0);
}
::-webkit-scrollbar-thumb:hover { background: var(--wisteria-dim); }

/* 背景星霞（canvas） */
#skyCanvas {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .8;
}
.aurora {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 520px at 8% -6%, rgba(217, 179, 108, .10), transparent 60%),
    radial-gradient(1000px 700px at 96% 104%, rgba(122, 98, 196, .13), transparent 62%),
    radial-gradient(600px 400px at 60% 40%, rgba(164, 147, 230, .045), transparent 70%);
}

/* ============ 骨格 ============ */
#app { position: relative; z-index: 1; display: flex; height: 100vh; }

/* --- サイドバー --- */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(18, 15, 28, .92), rgba(11, 9, 18, .96));
  border-right: 1px solid var(--gold-line);
  backdrop-filter: blur(6px);
}
.brand {
  padding: 26px 22px 20px;
  border-bottom: 1px solid rgba(217, 179, 108, .12);
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; flex: none; filter: drop-shadow(0 0 12px rgba(217, 179, 108, .35)); }
.brand-name {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 600; letter-spacing: .14em;
  background: linear-gradient(120deg, var(--gold-bright), var(--gold) 55%, var(--wisteria));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand-sub {
  margin-top: 2px; font-size: 10px; letter-spacing: .3em;
  color: var(--moon-faint); text-transform: uppercase;
}

.nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-section {
  font-size: 10px; letter-spacing: .24em; color: var(--moon-faint);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--moon-dim); cursor: pointer; user-select: none;
  border: 1px solid transparent;
  transition: all .22s var(--ease);
  font-size: 13.5px;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .75; transition: all .22s var(--ease); }
.nav-item:hover { background: var(--ink-2); color: var(--moon); }
.nav-item.active {
  background: linear-gradient(120deg, rgba(217, 179, 108, .14), rgba(122, 98, 196, .10));
  border-color: var(--gold-line);
  color: var(--gold-bright);
}
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 10px; padding: 1px 7px;
  background: rgba(217, 179, 108, .16); color: var(--gold);
  border-radius: 99px;
}

.side-foot { padding: 14px 16px 18px; border-top: 1px solid rgba(217, 179, 108, .12); }
.moon-widget {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(25, 21, 39, .8); border: 1px solid var(--ink-4);
}
.moon-widget canvas { width: 34px; height: 34px; flex: none; }
.moon-widget .mw-name { font-size: 12px; color: var(--moon); font-family: var(--font-display); letter-spacing: .08em; }
.moon-widget .mw-note { font-size: 10px; color: var(--moon-faint); }
.streak-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding: 0 4px;
  font-size: 11px; color: var(--moon-dim);
}
.streak-row b { color: var(--gold-bright); font-size: 15px; font-family: var(--font-display); }

/* --- メイン --- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 32px 14px;
}
.topbar-titles { flex: 1; min-width: 0; }
.view-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: 22px; letter-spacing: .1em; color: var(--moon);
}
.view-title .accent { color: var(--gold); }
.view-sub { font-size: 12px; color: var(--moon-faint); margin-top: 1px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content {
  flex: 1; overflow-y: auto; padding: 10px 32px 60px;
  scroll-behavior: smooth;
}

/* 画面切替アニメーション */
.view { display: none; }
.view.active { display: block; animation: viewIn .45s var(--ease) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.stagger > * { animation: viewIn .5s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .03s; }
.stagger > *:nth-child(2) { animation-delay: .08s; }
.stagger > *:nth-child(3) { animation-delay: .13s; }
.stagger > *:nth-child(4) { animation-delay: .18s; }
.stagger > *:nth-child(5) { animation-delay: .23s; }
.stagger > *:nth-child(6) { animation-delay: .28s; }

/* ============ 汎用コンポーネント ============ */

/* カード */
.card {
  background: linear-gradient(165deg, rgba(28, 23, 43, .82), rgba(20, 16, 32, .9));
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  position: relative;
}
.card + .card { margin-top: 18px; }
.card-title {
  font-family: var(--font-display); font-size: 15px; letter-spacing: .12em;
  color: var(--gold-bright); margin-bottom: 4px; font-weight: 600;
  display: flex; align-items: center; gap: 9px;
}
.card-title svg { width: 17px; height: 17px; }
.card-desc { font-size: 12px; color: var(--moon-faint); margin-bottom: 14px; }

/* 区切り金線 */
.hairline {
  height: 1px; margin: 18px 0;
  background: linear-gradient(90deg, transparent, var(--gold-line-strong), transparent);
}

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: 10px;
  font-family: var(--font-body); font-size: 13px; letter-spacing: .06em;
  cursor: pointer; user-select: none; border: 1px solid transparent;
  transition: all .22s var(--ease);
  position: relative; overflow: hidden; white-space: nowrap;
  background: var(--ink-3); color: var(--moon);
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { transform: translateY(-1px); background: var(--ink-4); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(120deg, var(--gold-deep), var(--gold) 60%, var(--gold-bright));
  color: #201708; font-weight: 700; border: none;
  box-shadow: 0 4px 18px rgba(217, 179, 108, .25);
}
.btn-primary::after {
  content: ""; position: absolute; top: 0; left: -80%;
  width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent);
  transform: skewX(-20deg); transition: left .5s var(--ease);
}
.btn-primary:hover { background: linear-gradient(120deg, var(--gold), var(--gold-bright)); box-shadow: 0 6px 24px rgba(217, 179, 108, .4); }
.btn-primary:hover::after { left: 130%; }

.btn-ghost { background: transparent; border-color: var(--ink-4); color: var(--moon-dim); }
.btn-ghost:hover { border-color: var(--gold-line-strong); color: var(--gold-bright); background: rgba(217, 179, 108, .06); }
.btn-danger { background: rgba(224, 133, 133, .12); color: var(--ember); border-color: rgba(224, 133, 133, .3); }
.btn-danger:hover { background: rgba(224, 133, 133, .2); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 13px 28px; font-size: 14.5px; border-radius: 12px; }
.btn-block { width: 100%; }

/* 入力 */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 11.5px; color: var(--moon-dim);
  letter-spacing: .08em; margin-bottom: 5px;
}
.field label .req { color: var(--ember); margin-left: 3px; }
.field label .opt { color: var(--moon-faint); font-size: 10px; margin-left: 6px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 13px;
  background: rgba(14, 11, 22, .85);
  border: 1px solid var(--ink-4); border-radius: var(--radius-sm);
  color: var(--moon); font-family: var(--font-body); font-size: 13.5px;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.7; }
input:focus, select:focus, textarea:focus {
  border-color: var(--gold-line-strong);
  box-shadow: 0 0 0 3px rgba(217, 179, 108, .12);
}
input::placeholder, textarea::placeholder { color: var(--moon-faint); opacity: .7; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23b7b1c9' fill='none' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.hint { font-size: 11px; color: var(--moon-faint); margin-top: 4px; line-height: 1.6; }
.hint a { color: var(--wisteria); }

/* チップ・タグ */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 11px; border-radius: 99px;
  font-size: 11.5px; letter-spacing: .04em;
  background: rgba(164, 147, 230, .12); color: var(--wisteria);
  border: 1px solid rgba(164, 147, 230, .25);
}
.chip-gold { background: rgba(217, 179, 108, .12); color: var(--gold); border-color: var(--gold-line); }
.chip-jade { background: rgba(127, 211, 178, .1); color: var(--jade); border-color: rgba(127, 211, 178, .28); }
.chip-ember { background: rgba(224, 133, 133, .1); color: var(--ember); border-color: rgba(224, 133, 133, .28); }
.chip-dim { background: var(--ink-3); color: var(--moon-dim); border-color: var(--ink-4); }
.chip.clickable { cursor: pointer; transition: all .18s; }
.chip.clickable:hover { transform: translateY(-1px); border-color: var(--gold-line-strong); color: var(--gold-bright); }

/* タブ */
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: rgba(14, 11, 22, .7); border: 1px solid var(--ink-4);
  border-radius: 11px; width: fit-content; margin-bottom: 18px;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 16px; border-radius: 8px; font-size: 12.5px;
  color: var(--moon-dim); cursor: pointer; transition: all .2s var(--ease);
  border: 1px solid transparent; user-select: none;
}
.tab:hover { color: var(--moon); }
.tab.active {
  background: linear-gradient(120deg, rgba(217, 179, 108, .16), rgba(122, 98, 196, .1));
  border-color: var(--gold-line); color: var(--gold-bright);
}

/* 統計カード */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: linear-gradient(160deg, rgba(28, 23, 43, .85), rgba(18, 14, 30, .92));
  border: 1px solid var(--gold-line); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; top: -30px; right: -30px;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 179, 108, .12), transparent 70%);
}
.stat-label { font-size: 11px; color: var(--moon-faint); letter-spacing: .1em; }
.stat-value {
  font-family: var(--font-display); font-size: 26px; font-weight: 600;
  color: var(--gold-bright); letter-spacing: .04em; line-height: 1.3; margin-top: 2px;
}
.stat-value small { font-size: 13px; color: var(--moon-dim); margin-left: 4px; }
.stat-note { font-size: 10.5px; color: var(--moon-faint); margin-top: 2px; }

/* グリッド */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
/* 中間幅〜スマホ: 1カラムに畳み、プレビューを上に固定（flex列＋edit-col解体でsticky追従を効かせる） */
@media (max-width: 900px) {
  .split { display: flex; flex-direction: column; gap: 18px; }
  .split > .edit-col { display: contents; }   /* preview-stickyを.split直下に出し、可動域を確保 */
  .split > .edit-col > .preview-sticky { order: -1; }
  .preview-card .phone-frame { max-width: 200px; }
}

/* テンプレートギャラリー */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 15px; }
.tpl-card {
  background: linear-gradient(165deg, rgba(30, 25, 46, .85), rgba(19, 15, 31, .93));
  border: 1px solid var(--ink-4); border-radius: var(--radius);
  padding: 18px; cursor: pointer; position: relative; overflow: hidden;
  transition: all .28s var(--ease);
}
.tpl-card:hover {
  transform: translateY(-4px); border-color: var(--gold-line-strong);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5), 0 0 0 1px rgba(217, 179, 108, .15);
}
.tpl-card.selected {
  border-color: var(--gold); background: linear-gradient(165deg, rgba(217, 179, 108, .13), rgba(19, 15, 31, .95));
  box-shadow: 0 0 0 1px var(--gold-line-strong), 0 10px 30px rgba(0,0,0,.4);
}
.tpl-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(217, 179, 108, .18), rgba(122, 98, 196, .16));
  border: 1px solid var(--gold-line); margin-bottom: 12px;
  font-size: 20px;
}
.tpl-name { font-family: var(--font-display); font-size: 14.5px; color: var(--moon); letter-spacing: .06em; font-weight: 600; }
.tpl-copy { font-size: 11.5px; color: var(--moon-faint); margin-top: 5px; line-height: 1.65; min-height: 38px; }
.tpl-meta { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.tpl-hot {
  position: absolute; top: 12px; right: 12px;
  font-size: 9.5px; letter-spacing: .12em; padding: 2px 8px;
  background: linear-gradient(120deg, var(--gold-deep), var(--gold));
  color: #201708; border-radius: 99px; font-weight: 700;
}

/* スマホプレビュー枠（9:16） */
.phone-frame {
  width: 100%; max-width: 300px; margin: 0 auto;
  aspect-ratio: 9 / 16; border-radius: 22px;
  border: 1px solid var(--gold-line-strong);
  background: #000; overflow: hidden; position: relative;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .6), 0 0 0 4px rgba(20, 16, 32, .9);
}
.phone-frame canvas { width: 100%; height: 100%; display: block; }
.preview-nav {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 14px;
}
.preview-count { font-size: 12px; color: var(--moon-dim); font-family: var(--font-display); letter-spacing: .1em; min-width: 60px; text-align: center; }

/* スライド編集リスト */
.slide-list { display: flex; flex-direction: column; gap: 10px; }
.slide-item {
  display: flex; gap: 12px; padding: 12px 14px;
  background: rgba(14, 11, 22, .7); border: 1px solid var(--ink-4);
  border-radius: var(--radius-sm); transition: border-color .2s;
}
.slide-item:hover { border-color: var(--wisteria-dim); }
.slide-item.editing { border-color: var(--gold-line-strong); box-shadow: 0 0 0 3px rgba(217,179,108,.08); }
.slide-no {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: linear-gradient(135deg, rgba(217, 179, 108, .16), rgba(122, 98, 196, .14));
  border: 1px solid var(--gold-line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 13px; color: var(--gold-bright);
}
.slide-body { flex: 1; min-width: 0; }
.slide-role { font-size: 10px; letter-spacing: .14em; color: var(--wisteria); margin-bottom: 2px; }
.slide-text-view { font-size: 13px; color: var(--moon); white-space: pre-wrap; line-height: 1.7; cursor: text; }
.slide-text-view:hover { color: var(--gold-bright); }
.slide-item textarea { min-height: 60px; font-size: 13px; }
.slide-actions { display: flex; flex-direction: column; gap: 5px; }
.icon-btn {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--ink-4);
  background: transparent; color: var(--moon-faint); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .18s;
}
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn:hover { border-color: var(--gold-line-strong); color: var(--gold-bright); background: rgba(217,179,108,.07); }
.icon-btn.danger:hover { border-color: rgba(224,133,133,.5); color: var(--ember); background: rgba(224,133,133,.07); }

/* 出力ボックス（キャプション等） */
.output-box {
  background: rgba(14, 11, 22, .8); border: 1px solid var(--ink-4);
  border-radius: var(--radius-sm); padding: 14px 16px;
  font-size: 13px; white-space: pre-wrap; line-height: 1.8;
  position: relative; color: var(--moon);
  max-height: 320px; overflow-y: auto;
}
.copy-btn { position: absolute; top: 10px; right: 10px; }

/* カレンダー */
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.cal-day {
  background: rgba(18, 14, 30, .8); border: 1px solid var(--ink-4);
  border-radius: var(--radius-sm); padding: 12px; min-height: 150px;
  transition: border-color .2s; position: relative;
}
.cal-day.today { border-color: var(--gold-line-strong); background: linear-gradient(170deg, rgba(217, 179, 108, .08), rgba(18, 14, 30, .85)); }
.cal-day-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.cal-dow { font-family: var(--font-display); font-size: 13px; color: var(--gold); letter-spacing: .1em; }
.cal-date { font-size: 10.5px; color: var(--moon-faint); }
.cal-today-tag { margin-left: auto; font-size: 9px; color: #201708; background: var(--gold); padding: 1px 6px; border-radius: 99px; font-weight: 700; }
.cal-task {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; margin: 4px 0; border-radius: 7px;
  background: rgba(30, 25, 46, .7); border: 1px solid transparent;
  font-size: 11px; color: var(--moon-dim); cursor: pointer;
  transition: all .18s;
}
.cal-task:hover { border-color: var(--gold-line); color: var(--moon); }
.cal-task.done { opacity: .5; text-decoration: line-through; }
.cal-task .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* テーブル */
.table-wrap { overflow-x: auto; border: 1px solid var(--ink-4); border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left; padding: 10px 14px;
  background: rgba(14, 11, 22, .9); color: var(--moon-faint);
  font-size: 11px; letter-spacing: .1em; font-weight: 500;
  border-bottom: 1px solid var(--ink-4); white-space: nowrap;
}
table.data td { padding: 10px 14px; border-bottom: 1px solid rgba(44, 37, 66, .5); color: var(--moon-dim); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(217, 179, 108, .03); color: var(--moon); }

/* リスト行（ストック・ネタ帳） */
.row-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border: 1px solid var(--ink-4);
  border-radius: var(--radius-sm); margin-bottom: 9px;
  background: rgba(18, 14, 30, .75);
  transition: all .2s var(--ease); cursor: pointer;
}
.row-item:hover { border-color: var(--gold-line-strong); transform: translateX(3px); }
.row-icon {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: linear-gradient(135deg, rgba(217, 179, 108, .13), rgba(122, 98, 196, .12));
  border: 1px solid var(--gold-line);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 13.5px; color: var(--moon); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 11px; color: var(--moon-faint); margin-top: 1px; }
.row-side { display: flex; align-items: center; gap: 8px; flex: none; }

/* ステータスピル */
.pill { font-size: 10.5px; padding: 2px 10px; border-radius: 99px; letter-spacing: .06em; white-space: nowrap; }
.pill.draft { background: rgba(164, 147, 230, .13); color: var(--wisteria); }
.pill.scheduled { background: rgba(229, 181, 103, .13); color: var(--amber); }
.pill.posted { background: rgba(127, 211, 178, .12); color: var(--jade); }

/* モーダル */
.modal-veil {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(7, 5, 12, .72); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  animation: veilIn .25s ease both; padding: 30px;
}
@keyframes veilIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 620px; max-height: 86vh; overflow-y: auto;
  background: linear-gradient(170deg, #1d1830, #120f1e);
  border: 1px solid var(--gold-line-strong); border-radius: 18px;
  box-shadow: var(--shadow-pop); padding: 28px 30px;
  animation: modalIn .35s var(--ease) both;
}
.modal.wide { max-width: 860px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(22px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-title {
  font-family: var(--font-display); font-size: 18px; color: var(--gold-bright);
  letter-spacing: .1em; margin-bottom: 4px; font-weight: 600;
}
.modal-title svg { width: 18px; height: 18px; vertical-align: -3px; }
.modal-sub { font-size: 12px; color: var(--moon-faint); margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* トースト */
#toastZone { position: fixed; bottom: 26px; right: 26px; z-index: 120; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 12px;
  background: linear-gradient(140deg, #241d3a, #171226);
  border: 1px solid var(--gold-line-strong);
  box-shadow: var(--shadow-pop); font-size: 13px; color: var(--moon);
  animation: toastIn .35s var(--ease) both; max-width: 380px;
}
.toast.out { animation: toastOut .3s ease both; }
.toast svg { width: 16px; height: 16px; flex: none; }
.toast.ok svg { color: var(--jade); }
.toast.err svg { color: var(--ember); }
.toast.info svg { color: var(--wisteria); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* 空状態 */
.empty {
  text-align: center; padding: 46px 20px; color: var(--moon-faint);
}
.empty svg { width: 44px; height: 44px; opacity: .4; margin-bottom: 12px; }
.empty .empty-title { font-family: var(--font-display); font-size: 15px; color: var(--moon-dim); letter-spacing: .1em; margin-bottom: 4px; }
.empty .empty-sub { font-size: 12px; line-height: 1.7; }

/* プログレスバー */
.progress-track { height: 7px; border-radius: 99px; background: var(--ink-3); overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright));
  transition: width .5s var(--ease);
  box-shadow: 0 0 10px rgba(217, 179, 108, .5);
}

/* AI状態インジケータ */
.ai-status { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--moon-dim); }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--moon-faint); }
.ai-dot.on { background: var(--jade); box-shadow: 0 0 8px rgba(127, 211, 178, .7); animation: pulse 2.4s infinite; }
.ai-dot.off { background: var(--amber); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* 生成中スピナー */
.casting {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 40px 0; color: var(--moon-dim); font-size: 13px;
}
.casting .orb {
  width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid var(--gold-line);
  border-top-color: var(--gold-bright);
  animation: spin 1.1s linear infinite;
  position: relative;
}
.casting .orb::after {
  content: ""; position: absolute; inset: 8px; border-radius: 50%;
  border: 1px solid rgba(164, 147, 230, .3); border-bottom-color: var(--wisteria);
  animation: spin 1.8s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* インラインアイコンの標準サイズ（親にルールが無い場所での巨大化防止） */
.lint-item svg { width: 15px; height: 15px; flex: none; margin-top: 3px; }
.flow-name svg { width: 15px; height: 15px; vertical-align: -2px; }
.row-icon svg { width: 18px; height: 18px; }
.row-side .btn svg { width: 13px; height: 13px; }

/* 安心チェック（コンプラ検出） */
.lint-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 12px; border-radius: 8px; margin-top: 8px;
  background: rgba(229, 181, 103, .07); border: 1px solid rgba(229, 181, 103, .25);
  font-size: 12px; color: var(--moon-dim);
}
.lint-item.ok { background: rgba(127, 211, 178, .06); border-color: rgba(127, 211, 178, .22); }
.lint-item b { color: var(--amber); }
.lint-item.ok b { color: var(--jade); }

/* オンボーディング */
.onboard-steps { display: flex; gap: 10px; margin: 18px 0; }
.onboard-step {
  flex: 1; padding: 16px 14px; border-radius: 12px;
  background: rgba(14, 11, 22, .7); border: 1px solid var(--ink-4);
  text-align: center;
}
.onboard-step .os-no {
  width: 30px; height: 30px; margin: 0 auto 8px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-deep), var(--gold));
  color: #201708; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
}
.onboard-step .os-t { font-size: 12.5px; color: var(--moon); margin-bottom: 3px; }
.onboard-step .os-d { font-size: 10.5px; color: var(--moon-faint); line-height: 1.6; }

/* 今日の一手（ダッシュボード主役カード） */
.hero-card {
  background:
    radial-gradient(500px 260px at 90% -20%, rgba(217, 179, 108, .16), transparent 65%),
    radial-gradient(400px 300px at -10% 120%, rgba(122, 98, 196, .18), transparent 60%),
    linear-gradient(160deg, #221b38, #14101f);
  border: 1px solid var(--gold-line-strong);
  border-radius: 18px; padding: 30px 34px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 18px;
}
.hero-kicker { font-size: 11px; letter-spacing: .3em; color: var(--gold); margin-bottom: 8px; }
.hero-title {
  font-family: var(--font-display); font-size: 25px; font-weight: 600;
  color: var(--moon); letter-spacing: .08em; line-height: 1.5; margin-bottom: 6px;
}
.hero-sub { font-size: 12.5px; color: var(--moon-dim); margin-bottom: 20px; max-width: 560px; }
.hero-moon-art { position: absolute; right: 30px; top: 50%; transform: translateY(-50%); opacity: .9; }

/* チャート */
.chart-box { padding: 8px 0 0; }
.chart-box canvas { width: 100%; height: 200px; display: block; }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 11px; color: var(--moon-faint); flex-wrap: wrap; }
.legend .lg { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }

/* DMフローステップ */
.flow-step { display: flex; gap: 16px; position: relative; padding-bottom: 22px; }
.flow-step::before {
  content: ""; position: absolute; left: 15px; top: 34px; bottom: 0;
  width: 1px; background: linear-gradient(180deg, var(--gold-line-strong), transparent);
}
.flow-step:last-child::before { display: none; }
.flow-no {
  width: 31px; height: 31px; flex: none; border-radius: 50%;
  background: linear-gradient(135deg, rgba(217, 179, 108, .2), rgba(122, 98, 196, .18));
  border: 1px solid var(--gold-line-strong);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); color: var(--gold-bright); font-size: 13px;
  z-index: 1;
}
.flow-body { flex: 1; min-width: 0; }
.flow-name { font-size: 13.5px; color: var(--moon); font-weight: 600; letter-spacing: .04em; }
.flow-goal { font-size: 11px; color: var(--moon-faint); margin: 2px 0 8px; }

/* 設定ページ */
.settings-nav-note {
  font-size: 11px; color: var(--moon-faint);
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: rgba(164, 147, 230, .06); border: 1px dashed rgba(164, 147, 230, .3);
  line-height: 1.7;
}
.key-safe {
  display: flex; align-items: flex-start; gap: 8px; font-size: 11px; color: var(--moon-faint);
  line-height: 1.7; margin-top: 6px;
}
.key-safe svg { width: 13px; height: 13px; flex: none; margin-top: 3px; color: var(--jade); }

/* kbd */
kbd {
  font-family: var(--font-body); font-size: 10.5px;
  padding: 2px 7px; border-radius: 5px;
  background: var(--ink-3); border: 1px solid var(--ink-4);
  border-bottom-width: 2px; color: var(--moon-dim);
}

/* バナー（注意書き） */
.note-banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: rgba(217, 179, 108, .06); border: 1px solid var(--gold-line);
  font-size: 12px; color: var(--moon-dim); line-height: 1.7; margin-bottom: 16px;
}
.note-banner svg { width: 15px; height: 15px; flex: none; margin-top: 3px; color: var(--gold); }

/* ボトムナビ（スマホ用・700px以下で表示） */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
  background: rgba(14, 11, 22, .96);
  border-top: 1px solid var(--gold-line);
  backdrop-filter: blur(12px);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--moon-faint); font-size: 9.5px; letter-spacing: .04em;
  padding: 5px 10px; border-radius: 9px; cursor: pointer; min-width: 54px;
  transition: color .2s; user-select: none; -webkit-tap-highlight-color: transparent;
}
.bn-item svg { width: 21px; height: 21px; }
.bn-item.active { color: var(--gold-bright); }
.bn-item:active { transform: scale(.94); }

/* レスポンシブ */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .cal-week { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 840px) {
  .sidebar { width: 66px; min-width: 66px; }
  .brand-name, .brand-sub, .nav-item span, .nav-section, .moon-widget .mw-text, .streak-row, .nav-badge { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .moon-widget { justify-content: center; padding: 8px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 8px 18px 50px; }
  .topbar { padding: 16px 18px 10px; }
  .cal-week { grid-template-columns: repeat(2, 1fr); }
  .onboard-steps { flex-direction: column; }
}
/* スマホ（サイドバー非表示＋ボトムナビ） */
@media (max-width: 700px) {
  body { font-size: 13.5px; }
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .content { padding: 4px 13px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .topbar { padding: 13px 14px 8px; gap: 8px; flex-wrap: wrap; }
  .view-title { font-size: 17.5px; }
  .view-sub { font-size: 10.5px; }
  .topbar-actions { flex: 1 0 100%; justify-content: space-between; }
  #accountSwitch { min-width: 0 !important; max-width: 55%; }
  .hero-card { padding: 20px 18px; }
  .hero-title { font-size: 18px; }
  .hero-sub { font-size: 11.5px; }
  .hero-moon-art { display: none; }
  .card { padding: 16px 15px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 20px; }
  .field-row { flex-direction: column; gap: 0; }
  .tpl-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tpl-copy { min-height: 0; }
  .tabs { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }
  .cal-week { grid-template-columns: 1fr 1fr; }
  .phone-frame { max-width: 240px; }
  .modal-veil { padding: 12px; }
  .modal { padding: 20px 17px; max-height: 90vh; }
  #toastZone { left: 12px; right: 12px; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .toast { max-width: none; }
  .btn-lg { padding: 11px 18px; font-size: 13px; }
  .flow-step::before { left: 13px; }
}

/* 印刷（台本の印刷用） */
@media print {
  .sidebar, .topbar-actions, #toastZone, .aurora, #skyCanvas { display: none !important; }
  body { background: #fff; color: #111; overflow: visible; }
  .content { overflow: visible; }
}

/* ---------- v5: プレビュー直接編集 ---------- */
#rsPreview { cursor: grab; touch-action: none; }
.quick-edit {
  margin-top: 12px; padding: 12px 13px;
  background: rgba(14, 11, 22, .55);
  border: 1px solid var(--ink-4); border-radius: 10px;
}
.quick-edit .qe-title {
  font-size: 12.5px; font-weight: 700; color: var(--gold);
  margin-bottom: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.quick-edit .qe-title svg { width: 14px; height: 14px; }
.quick-edit .qe-title .opt { font-weight: 500; }
.preview-nav { flex-wrap: wrap; }

/* v7: 選択文字の装飾ツールバー */
.qe-seltools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.qe-seltools input[type="color"] { width: 34px; height: 28px; padding: 2px; }

/* ============================================================
   v9: プレビュー横編集レイアウト・配置・選択ツール拡張
   ============================================================ */
/* v11: プレビューを独立カラムに分離（編集UIと重ならない）
   .split = [操作カラム(controls-col) | プレビュー(edit-col・sticky)] */
/* edit-colはグリッド行いっぱいに伸ばす→sticky可動域を確保（中身=プレビューだけだと固定できない） */
.edit-col { display: flex; flex-direction: column; gap: 18px; align-self: stretch; }
.preview-sticky { position: sticky; top: 10px; z-index: 5; align-self: stretch; }
/* 独立カラムなので編集欄と干渉しない → プレビューは大きく見せる */
.preview-card .phone-frame { max-width: 300px; margin: 0 auto; }
.preview-card {
  padding: 14px 18px 14px;
  background: linear-gradient(165deg, #1e1930, #14101f);
  box-shadow: 0 16px 40px rgba(0,0,0,.6), 0 0 0 1px var(--gold-line-strong);
  display: flex; flex-direction: column; align-items: stretch;
}
.preview-card .card-title { margin-bottom: 6px; font-size: 13px; }
.preview-card .preview-nav { margin-top: 10px; }
.controls-col { min-width: 0; }

/* 9か所ワンタップ配置 */
.qe-place-wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.qe-place {
  display: grid; grid-template-columns: repeat(3, 30px); grid-template-rows: repeat(3, 26px);
  gap: 4px; flex: none;
}
.qe-place-btn {
  border: 1px solid var(--ink-4); background: rgba(14, 11, 22, .7);
  border-radius: 6px; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.qe-place-btn span { width: 12px; height: 3px; border-radius: 2px; background: var(--moon-faint); display: block; transition: all .15s; }
.qe-place-btn:hover { border-color: var(--gold-line-strong); }
.qe-place-btn.on { border-color: var(--gold); background: rgba(217, 179, 108, .16); }
.qe-place-btn.on span { background: var(--gold-bright); }
.qe-place-side { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* 選択文字ツールバー */
.qe-seltools { margin-top: 8px; padding: 10px 11px; background: rgba(14, 11, 22, .5); border: 1px solid var(--ink-4); border-radius: 9px; display: flex; flex-direction: column; gap: 7px; }
.qe-selhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.qe-selstat { font-size: 10.5px; color: var(--moon-faint); border: 1px solid var(--ink-4); border-radius: 99px; padding: 1px 9px; white-space: nowrap; }
.qe-selstat.on { color: #201708; background: var(--gold); border-color: var(--gold); font-weight: 700; }
.qe-selrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.qe-sellabel { font-size: 11px; color: var(--moon-dim); min-width: 48px; }
.qe-seltools .btn-sm { padding: 4px 9px; font-size: 11.5px; }
.qe-seltools input[type="color"] { width: 32px; height: 26px; padding: 2px; }
.qe-swatches { display: inline-flex; gap: 5px; }
.qe-swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid rgba(255,255,255,.22); transition: transform .12s; }
.qe-swatch:hover { transform: scale(1.15); border-color: var(--gold-bright); }

/* この画面だけの演出（折りたたみ） */
.qe-adv { margin-top: 12px; border-top: 1px solid var(--ink-4); padding-top: 10px; }
.qe-adv summary { cursor: pointer; font-size: 12.5px; color: var(--gold); font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; }
.qe-adv summary::-webkit-details-marker { display: none; }
.qe-adv summary svg { width: 14px; height: 14px; }
.qe-adv summary::after { content: "▾ 開く"; margin-left: auto; font-size: 10.5px; font-weight: 500; color: var(--moon-faint); }
.qe-adv[open] summary::after { content: "▴ 閉じる"; }
.qe-adv summary:hover { color: var(--gold-bright); }
.qe-adv-body { margin-top: 12px; }

@media (max-width: 700px) {
  /* モバイルでもプレビューは上部固定（編集は下で完結） */
  .preview-sticky { top: 4px; }
  .preview-card { padding: 12px 14px; }
  .preview-card .phone-frame { max-width: 210px; }
  .qe-place { grid-template-columns: repeat(3, 28px); grid-template-rows: repeat(3, 24px); }
  /* プレビュー操作ボタンを指で押しやすく */
  .preview-card .preview-nav { gap: 8px; row-gap: 8px; }
  .preview-card .preview-nav .btn { min-height: 40px; padding: 9px 13px; font-size: 13px; }
  .preview-card .preview-nav .preview-count { min-width: 46px; font-size: 11px; }
  /* 拡大モーダルはスマホ幅いっぱい＋ボタン大きめ（再生/ナビが見切れないよう高さ抑えめ） */
  .big-preview { height: min(50vh, 440px); }
  .modal .preview-nav { gap: 8px; }
  .modal .preview-nav .btn { min-height: 44px; }
  .modal.wide { padding: 18px 16px; }
}
/* プレビュー(小・大)は指ドラッグでスクロール横取りしない＝文字移動が効く */
#rsPreview, .big-preview canvas { touch-action: none; }

/* v10: プレビュー拡大モーダル */
.big-preview {
  width: auto; height: min(72vh, 660px); aspect-ratio: 9 / 16;
  margin: 14px auto 0; border-radius: 20px;
  border: 1px solid var(--gold-line-strong); background: #000;
  overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.7);
}
.big-preview canvas { width: 100%; height: 100%; display: block; }

/* v13: 演出プリセットのチップ */
.preset-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.preset-chip {
  border: 1px solid var(--ink-4); background: rgba(20, 16, 32, .7);
  color: var(--moon-dim); border-radius: 99px; padding: 6px 12px;
  font-size: 12px; cursor: pointer; transition: all .16s; white-space: nowrap;
}
.preset-chip:hover { border-color: var(--gold-line-strong); color: var(--moon); transform: translateY(-1px); }
.preset-chip.rec { border-color: var(--gold-line-strong); color: var(--gold-bright); background: rgba(217, 179, 108, .1); }
