/* style.css — StackNovel（StackWorld ダークテーマ準拠 / #0d0f14 系） */

:root {
  color-scheme: dark;
  --bg0: #070a12;
  --bg1: #0d0f14;
  --text: rgba(255, 255, 255, .92);
  --muted: rgba(255, 255, 255, .60);
  --faint: rgba(255, 255, 255, .42);
  --shell: rgba(15, 23, 42, .94);
  --card: rgba(2, 6, 23, .55);
  --card2: rgba(15, 23, 42, .55);
  --line: rgba(255, 255, 255, .10);
  --line2: rgba(148, 163, 184, .35);
  --accent: rgba(129, 140, 248, .95);
  --accent-bg: rgba(99, 102, 241, .18);
  --accent-soft: rgba(99, 102, 241, .12);
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, .14);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .14);
  --danger: #fb7185;
  --danger-bg: rgba(251, 113, 133, .14);
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "MS Mincho", serif;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  color: var(--text);
  line-height: 1.65;
  background:
    radial-gradient(1200px 800px at 10% 0%, rgba(111, 123, 255, .12), transparent 55%),
    radial-gradient(900px 700px at 90% 8%, rgba(56, 189, 248, .08), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0; }
a { color: #a5b4fc; text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .3); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, .5); background-clip: content-box; }

/* ---------- レイアウト ---------- */
.page { min-height: 100%; padding: 16px; display: flex; justify-content: center; }
.shell {
  width: min(1120px, 100%);
  border-radius: 22px;
  background: var(--shell);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .85), 0 0 0 1px rgba(148, 163, 184, .18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- ヘッダー ---------- */
.app-header {
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 6, 23, .35);
  user-select: none;
}
.header-left { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.logo-orb {
  width: 38px; height: 38px; border-radius: 999px; flex-shrink: 0;
  background:
    radial-gradient(circle at 30% 20%, #38bdf8, transparent 55%),
    radial-gradient(circle at 80% 80%, #6366f1, transparent 55%),
    radial-gradient(circle at 10% 90%, #818cf8, transparent 55%);
  box-shadow: 0 0 0 2px rgba(248, 250, 252, .15), 0 12px 30px rgba(0, 0, 0, .8);
}
.logo-text-block { display: flex; flex-direction: column; gap: 1px; }
.logo-main { font-size: 17px; letter-spacing: .14em; font-weight: 900; }
.logo-sub { font-size: 10.5px; opacity: .7; }
.header-right { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 999px; font-size: 12px;
  background: rgba(15, 23, 42, .85);
  border: 1px solid var(--line2);
  white-space: nowrap;
}
.pill strong { font-weight: 900; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  font-size: 12.5px; font-weight: 800;
  border: 1px solid var(--line2);
  background: rgba(15, 23, 42, .75);
  color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .08s ease-out, filter .08s ease-out, background .12s, border-color .12s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent-bg); border-color: var(--accent); color: #fff; }
.btn-ghost { background: rgba(15, 23, 42, .5); border-color: var(--line2); }
.btn-danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-lg { padding: 11px 20px; font-size: 13.5px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: rgba(148, 163, 184, .14); color: var(--text); }

/* ---------- バッジ・チップ ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800;
  background: rgba(148, 163, 184, .16); color: var(--muted);
}
.badge.brand { background: var(--accent-bg); color: #c7cbff; }
.badge.st-review { background: var(--warn-bg); color: var(--warn); }
.badge.st-approved { background: var(--ok-bg); color: var(--ok); }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; cursor: pointer; user-select: none;
  background: rgba(15, 23, 42, .75); border: 1px solid var(--line2); color: #cbd5e1;
  transition: border-color .12s, background .12s, color .12s;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent); color: #fff; }

.ok { color: var(--ok); font-weight: 900; }
.ng { color: var(--danger); font-weight: 900; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }

/* ---------- カード・面 ---------- */
.card { border: 1px solid var(--line); background: var(--card); border-radius: var(--r-lg); }
.panel { border: 1px solid var(--line); background: var(--card); border-radius: var(--r-lg); padding: 18px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 14px 0; }

/* ---------- フォーム ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 800; color: rgba(255, 255, 255, .82); }
.field-hint { font-size: 11.5px; color: var(--faint); }
.input, .textarea, select, .select {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--text);
  background: rgba(2, 6, 23, .5); border: 1px solid var(--line2);
  border-radius: var(--r); padding: 9px 12px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { resize: vertical; line-height: 1.8; min-height: 84px; }
select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23818cf8' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}

/* ---------- ユーティリティ ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

.sec-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.sec-title { font-size: 20px; font-weight: 800; }

/* 空状態 */
.empty { text-align: center; padding: 44px 20px; color: var(--faint); }
.empty-icon { font-size: 38px; margin-bottom: 10px; opacity: .8; }
.empty-title { font-weight: 800; color: var(--muted); margin-bottom: 4px; }

/* ---------- メイン領域 ---------- */
.content { padding: 18px; }

/* ---------- 作品一覧 ---------- */
.ad-banner {
  display: flex; align-items: center; gap: 10px;
  border: 1px dashed var(--line2); background: rgba(15, 23, 42, .4);
  border-radius: var(--r); padding: 10px 14px; color: var(--muted); font-size: 12.5px;
}
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(282px, 1fr)); gap: 14px; }
.proj-card {
  display: flex; flex-direction: column; gap: 11px; padding: 16px;
  border: 1px solid var(--line); background: var(--card2); border-radius: var(--r-lg);
  transition: border-color .15s, transform .06s, box-shadow .15s;
}
.proj-card:hover { border-color: var(--accent); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.proj-card-title { font-size: 16px; font-weight: 800; cursor: pointer; }
.proj-card-title:hover { color: #c7cbff; }
.proj-stat { display: flex; gap: 14px; font-size: 11.5px; color: var(--faint); }
.proj-stat b { color: var(--text); font-size: 14px; font-weight: 800; }

/* ---------- ドラッグ並び替え ---------- */
.drag-handle {
  cursor: grab; color: var(--faint); display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: var(--r-sm); user-select: none; flex-shrink: 0;
}
.drag-handle:hover { background: rgba(148, 163, 184, .14); color: var(--muted); }
.drag-handle:active { cursor: grabbing; }
[data-dragging] { opacity: .4; }
[data-over] { box-shadow: 0 -2px 0 0 var(--accent) inset, 0 2px 0 0 var(--accent); }

/* ---------- メニュー（ポップオーバー） ---------- */
.menu-wrap { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 168px; z-index: 80;
  background: var(--shell); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .6); padding: 6px;
}
.menu-pop.left { right: auto; left: 0; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px;
  border: 0; background: transparent; border-radius: var(--r-sm); cursor: pointer;
  font-size: 13px; font-weight: 700; text-align: left; color: var(--text);
}
.menu-item:hover { background: rgba(148, 163, 184, .12); }
.menu-item.danger { color: var(--danger); }
.menu-item .mi-ico { width: 16px; text-align: center; }

/* ---------- ウィザード ---------- */
.wizard-progress { display: flex; gap: 6px; margin-bottom: 14px; }
.wizard-progress > span { height: 5px; flex: 1; border-radius: 99px; background: rgba(148, 163, 184, .2); transition: background .2s; }
.wizard-progress > span[data-done] { background: var(--accent); opacity: .55; }
.wizard-progress > span[data-current] { background: var(--accent); }
.mode-card {
  flex: 1; text-align: left; padding: 18px; border-radius: var(--r-lg);
  border: 2px solid var(--line2); background: rgba(2, 6, 23, .4); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mode-card:hover { border-color: var(--accent); }
.mode-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.summary-row {
  display: grid; grid-template-columns: 120px 1fr; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.summary-row > .k { color: var(--faint); font-weight: 700; font-size: 12.5px; }

/* ---------- ワークスペース ---------- */
.workspace { display: grid; grid-template-columns: 226px 1fr; min-height: 60vh; }
.ws-sidebar {
  border-right: 1px solid var(--line); background: rgba(2, 6, 23, .3);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 3px;
}
.ws-nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 11px; border-radius: var(--r); border: none; background: transparent;
  color: var(--muted); font-size: 13.5px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.ws-nav-item:hover { background: rgba(148, 163, 184, .1); color: var(--text); text-decoration: none; }
.ws-nav-item.active { background: var(--accent-bg); color: #fff; }
.ws-nav-item .nav-ico { width: 20px; text-align: center; font-size: 15px; }
.ws-nav-item .nav-count { margin-left: auto; font-size: 11px; color: var(--faint); font-weight: 800; }
.ws-proj-title {
  padding: 4px 11px 10px; font-weight: 800; font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ws-content { min-width: 0; padding: 22px 24px 60px; }

/* 編集カード（キャラ・伏線・メモ等共通） */
.edit-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card2); overflow: hidden; }
.edit-card-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: rgba(2, 6, 23, .35); border-bottom: 1px solid var(--line);
}
.edit-card-head .input { background: transparent; border: none; }
.edit-card-body { padding: 15px; display: flex; flex-direction: column; gap: 13px; }

/* 章リスト行 */
.chapter-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card2);
  cursor: pointer; transition: border-color .15s;
}
.chapter-row:hover { border-color: var(--accent); }

/* 章編集タブ */
.tabs { display: flex; gap: 4px; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  padding: 9px 15px; border: none; background: transparent; color: var(--muted);
  font-size: 13.5px; font-weight: 700; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; border-bottom-color: var(--accent); }

/* 本文エディタ */
.manuscript { font-family: var(--serif); font-size: 15.5px; line-height: 2; }

/* ---------- トースト ---------- */
.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(2, 6, 23, .96); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 700; border: 1px solid var(--line2);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .7); transition: opacity .25s; animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- モーダル ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2, 4, 10, .6); display: grid; place-items: center;
  padding: 20px; z-index: 900; animation: fade .15s ease;
}
.modal {
  background: var(--shell); border: 1px solid var(--line2); border-radius: var(--r-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .8); width: 100%; max-width: 440px; padding: 22px;
  animation: pop .18s ease;
}
.modal-title { font-size: 17px; margin-bottom: 8px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }

/* ---------- フッター ---------- */
.footer-legal {
  padding: 14px 18px; border-top: 1px solid var(--line); background: rgba(2, 6, 23, .5);
  color: var(--muted); font-size: 11.5px; line-height: 1.7;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.footer-link {
  display: inline-flex; padding: 6px 11px; border-radius: 999px; font-size: 11px; font-weight: 800;
  background: rgba(15, 23, 42, .85); border: 1px solid var(--line2); color: #cbd5e1; text-decoration: none; white-space: nowrap;
}

/* ---------- スマホ ---------- */
@media (max-width: 760px) {
  .page { padding: 8px; }
  .content { padding: 12px; }
  .app-header { padding: 12px; }
  .header-right { justify-content: flex-start; }
  .grid-2 { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .ws-sidebar { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); }
  .ws-nav-item { width: auto; }
  .ws-proj-title { display: none; }
  .ws-content { padding: 16px; }
  /* iOS Safari のフォーカス時自動ズーム防止 */
  .input, .textarea, select { font-size: 16px; }
  .footer-links { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
