/* ============================================================
   AI株分析ランチャー — Phase 1
   トーン：明るい紙色のベース × 黒い「分析コンソール」× ライム
   ============================================================ */
:root {
  --bg: #f6f2ea;
  --paper: #fffdf8;
  --ink: #16181d;
  --ink-2: #3a3d45;
  --muted: #777a82;
  --line: #e7e0d2;
  --lime: #c8f53d;
  --lime-deep: #8fc400;
  --coral: #ff6a45;

  /* グループカラー */
  --c-core: #ff6a45;
  --c-fundamental: #14a38b;
  --c-market: #7a5cff;
  --c-event: #f59f0a;
  --c-risk: #e5484d;
  --c-special: #d6409f;

  --radius: 18px;
  --shadow: 0 1px 0 rgba(22, 24, 29, .06), 0 8px 24px -12px rgba(22, 24, 29, .18);
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* ── topbar ─────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: rgba(246, 242, 234, .86);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--lime);
  font-weight: 800; font-size: 18px;
  box-shadow: inset 0 -3px 0 rgba(200, 245, 61, .35);
}
.brand-text { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.brand-text b { font-weight: 800; }
.topbar-code {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 999px;
  padding: 6px 14px 6px 12px;
  background: var(--ink); color: var(--lime);
  font-family: var(--mono); font-weight: 800; font-size: 16px; letter-spacing: .08em;
}
.topbar-code::after { content: "変更"; font-family: var(--font); font-size: 11px; font-weight: 700; color: #b9bcc4; letter-spacing: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(200, 245, 61, .25); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(200, 245, 61, 0); } }

/* ── layout ─────────────────────────── */
.layout {
  max-width: 1280px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 500px);
  gap: 28px; padding: 24px 24px 40px;
  align-items: start;
}
.col-left { min-width: 0; }

/* ── hero ───────────────────────────── */
.hero { margin-bottom: 28px; }
.tagline { margin: 4px 0 14px; font-size: clamp(24px, 3.2vw, 34px); font-weight: 800; line-height: 1.35; letter-spacing: .01em; }
.tagline span { display: inline-block; font-size: .62em; font-weight: 700; color: var(--ink-2); }
.tagline em { font-style: normal; background: linear-gradient(transparent 58%, var(--lime) 58%); padding: 0 2px; }

.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; }
.steps li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px 5px 6px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--line);
  font-size: 13px; font-weight: 700; color: var(--muted);
  transition: all .2s;
}
.steps li i {
  font-style: normal; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: var(--line); color: var(--ink-2);
}
.steps li.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.steps li.active i { background: var(--lime); color: var(--ink); }
.steps li.done { color: var(--ink-2); }
.steps li.done i { background: var(--lime); color: var(--ink); font-size: 0; }
.steps li.done i::before { content: "✓"; font-size: 12px; }

.code-card {
  background: var(--paper); border: 2px solid var(--ink);
  border-radius: 22px; padding: 16px 18px 14px;
  box-shadow: 6px 6px 0 var(--ink);
  max-width: 560px;
}
.code-label { display: block; font-size: 13px; font-weight: 800; color: var(--ink-2); margin-bottom: 6px; }
.code-row { display: flex; gap: 10px; }
.code-row input {
  flex: 1; min-width: 0;
  font-family: var(--mono); font-size: 34px; font-weight: 800; letter-spacing: .18em;
  padding: 8px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.code-row input::placeholder { color: #d4cfc4; }
.code-row input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(200, 245, 61, .55); }
.btn-go {
  flex: none; border: 0; border-radius: 14px; padding: 0 22px;
  background: var(--lime); color: var(--ink);
  font-weight: 800; font-size: 17px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12);
  transition: transform .1s;
}
.btn-go:active { transform: translateY(2px); }
.code-hint { margin: 8px 2px 0; font-size: 12.5px; color: var(--muted); }
.code-hint.error { color: var(--c-risk); font-weight: 700; }
.recent { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.recent-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 3px 12px; font-family: var(--mono); font-weight: 800; font-size: 14px;
}
.chip:hover { border-color: var(--ink); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.code-locked {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 560px;
  padding: 14px 16px 14px 20px; border-radius: 22px;
  background: var(--ink); color: #fff;
  box-shadow: 6px 6px 0 var(--lime);
}
.locked-main small { display: block; font-size: 12px; font-weight: 700; color: #b9bcc4; }
.locked-main strong { font-family: var(--mono); font-size: 40px; font-weight: 800; letter-spacing: .14em; color: var(--lime); line-height: 1.1; }
.btn-change {
  border: 1.5px solid #4a4e58; background: transparent; color: #fff;
  border-radius: 12px; padding: 8px 16px; font-weight: 700; font-size: 14px;
}
.btn-change:hover { border-color: var(--lime); color: var(--lime); }

/* ── catalog ────────────────────────── */
.sec { margin-bottom: 34px; }
.sec-head { margin-bottom: 14px; }
.kicker { display: inline-block; font-family: var(--mono); font-size: 11px; font-weight: 800; letter-spacing: .16em; color: var(--muted); }
.sec-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.sec-head p { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); }

.grp { margin-bottom: 18px; }
.grp-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px 2px; }
.grp-label { font-family: var(--mono); font-size: 12px; font-weight: 800; letter-spacing: .12em; color: var(--gc); }
.grp-jp { font-size: 12px; font-weight: 700; color: var(--muted); }
.grp-core { --gc: var(--c-core); }
.grp-fundamental { --gc: var(--c-fundamental); }
.grp-market { --gc: var(--c-market); }
.grp-event { --gc: var(--c-event); }
.grp-risk { --gc: var(--c-risk); }
.grp-special { --gc: var(--c-special); }

/* 通常タイル */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 64px; text-align: left;
  padding: 10px 12px; border-radius: 16px;
  background: var(--paper); border: 1.5px solid var(--line);
  transition: transform .12s, border-color .12s, box-shadow .12s, background .12s;
}
.tile:hover { border-color: var(--gc); transform: translateY(-2px); box-shadow: var(--shadow); }
.tile:active { transform: translateY(0) scale(.98); }
.tile:focus-visible { outline: 3px solid var(--lime-deep); outline-offset: 2px; }
.t-emoji {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 21px;
  background: color-mix(in srgb, var(--gc) 13%, #fff);
}
.t-text { display: flex; flex-direction: column; min-width: 0; }
.t-name { font-weight: 800; font-size: 15px; line-height: 1.3; word-break: keep-all; overflow-wrap: anywhere; }
.t-short { font-size: 11.5px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.t-arrow { margin-left: auto; flex: none; font-weight: 800; color: var(--line); transition: color .12s, transform .12s; }
.tile:hover .t-arrow { color: var(--gc); transform: translateX(2px); }
.tiles .t-arrow { display: none; }
.tile.selected { border-color: var(--ink); background: #fff; box-shadow: 4px 4px 0 var(--gc); }
.tile.selected .t-arrow { color: var(--ink); }

/* CORE：大きく目立たせる */
.tiles-hero { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tiles-hero .tile { flex-direction: column; align-items: flex-start; gap: 8px; min-height: 150px; padding: 16px; border-width: 2px; border-color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.tiles-hero .tile:hover { box-shadow: 6px 6px 0 var(--ink); }
.tiles-hero .tile.selected { box-shadow: 6px 6px 0 var(--coral); }
.tiles-hero .t-emoji { width: 48px; height: 48px; font-size: 26px; border-radius: 14px; }
.tiles-hero .t-name { font-size: 18px; }
.tiles-hero .t-short { font-size: 12.5px; }
.tiles-hero .t-arrow { position: absolute; right: 14px; top: 14px; font-size: 18px; color: var(--ink); }
.tiles-hero .tile:nth-child(2) { background: #fff1ec; }
.tiles-hero .tile:nth-child(3) { background: #fff6e0; }
.tiles-hero .tile:nth-child(4) { background: #f1edff; }
.tiles-hero .tile-featured {
  grid-column: 1 / -1; min-height: 0;
  flex-direction: row; align-items: center; gap: 16px; padding: 20px 22px;
  background: var(--ink); color: #fff;
  box-shadow: 5px 5px 0 var(--lime);
}
.tiles-hero .tile-featured:hover { box-shadow: 7px 7px 0 var(--lime); }
.tiles-hero .tile-featured.selected { box-shadow: 7px 7px 0 var(--coral); }
.tiles-hero .tile-featured .t-emoji { width: 60px; height: 60px; font-size: 32px; border-radius: 16px; background: #2a2d35; }
.tiles-hero .tile-featured .t-name { font-size: 24px; }
.tiles-hero .tile-featured .t-name::after {
  content: "おすすめ"; margin-left: 10px; vertical-align: 3px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--lime); color: var(--ink); font-size: 11px; font-weight: 800;
}
.tiles-hero .tile-featured .t-short { color: #c3c6cd; font-size: 13.5px; }
.tiles-hero .tile-featured .t-arrow { position: static; color: var(--lime); font-size: 26px; }

/* コード未入力時は少し控えめに */
body:not(.has-code) .tile { opacity: .6; }
body:not(.has-code) .tile:hover { opacity: 1; }

.site-foot { font-size: 12px; color: var(--muted); padding: 8px 2px 0; border-top: 1px dashed var(--line); }

/* ── 右パネル ───────────────────────── */
.col-right {
  position: sticky; top: calc(var(--topbar-h) + 20px);
  height: calc(100vh - var(--topbar-h) - 40px);
  height: calc(100dvh - var(--topbar-h) - 40px);
  display: flex; flex-direction: column;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 24px;
  box-shadow: 8px 8px 0 var(--ink);
  overflow: hidden;
  --gc: var(--c-core);
}
.col-right[data-group="fundamental"] { --gc: var(--c-fundamental); }
.col-right[data-group="market"] { --gc: var(--c-market); }
.col-right[data-group="event"] { --gc: var(--c-event); }
.col-right[data-group="risk"] { --gc: var(--c-risk); }
.col-right[data-group="special"] { --gc: var(--c-special); }

.panel-empty { margin: auto; padding: 32px; text-align: center; }
.empty-emoji { font-size: 44px; animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(-8px); } }
.empty-title { margin: 8px 0 4px; font-size: 19px; font-weight: 800; }
.empty-sub { margin: 0; font-size: 13.5px; color: var(--muted); }
.btn-quick {
  margin-top: 18px; border: 2px solid var(--ink); border-radius: 14px;
  padding: 12px 20px; background: var(--lime); font-weight: 800; font-size: 15px;
  box-shadow: 3px 3px 0 var(--ink);
}
.btn-quick:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.panel-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-bar { display: none; }
.panel-head { padding: 20px 22px 12px; border-bottom: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; gap: 12px; }
.panel-emoji {
  flex: none; width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center; font-size: 28px;
  background: color-mix(in srgb, var(--gc) 15%, #fff);
}
.panel-group { font-family: var(--mono); font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--gc); }
.panel-title h2 { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.25; }
.panel-desc { margin: 10px 0 8px; font-size: 13.5px; color: var(--ink-2); line-height: 1.7; }
.points { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.points li {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--gc) 11%, #fff); color: var(--ink-2);
}
.points li::before { content: "✓ "; color: var(--gc); }

.prompt-box { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 14px 16px 0; border-radius: 16px; background: var(--ink); overflow: hidden; }
.prompt-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 14px; font-size: 11.5px; font-weight: 700; color: #9da1ab;
  border-bottom: 1px solid #2c2f37;
}
.prompt-live { display: inline-flex; align-items: center; gap: 7px; }
.prompt-live b { font-family: var(--mono); color: var(--lime); letter-spacing: .06em; }
.prompt-text {
  flex: 1; min-height: 0; margin: 0; overflow: auto;
  padding: 14px 16px 18px;
  font-family: var(--font); font-size: 13px; line-height: 1.75; font-weight: 500;
  color: #e6e7ea; white-space: pre-wrap; word-break: break-word;
  outline: none;
}
.prompt-text .h { color: #fff; font-weight: 800; }
.prompt-text mark { background: var(--lime); color: var(--ink); font-family: var(--mono); font-weight: 800; padding: 0 3px; border-radius: 4px; }
.prompt-text::-webkit-scrollbar { width: 8px; }
.prompt-text::-webkit-scrollbar-thumb { background: #3a3e48; border-radius: 8px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px 16px; }
.actions button {
  min-height: 54px; border-radius: 16px; border: 2px solid var(--ink);
  font-weight: 800; font-size: 16px;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .15s;
}
.actions button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-copy { background: #fff; }
.btn-copy.copied { background: var(--lime); }
.btn-gpt { background: var(--ink); color: #fff; }
.btn-gpt:hover { background: #262a33; }
.howto { grid-column: 1 / -1; margin: 0; font-size: 11.5px; color: var(--muted); text-align: center; }
.howto b { color: var(--ink-2); }

/* ── toast ───────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 460px);
  padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 700; text-align: center;
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .45);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--ink); box-shadow: 0 0 0 3px var(--lime), 0 12px 30px -8px rgba(0, 0, 0, .45); }
.toast.warn { background: #3b1d1d; }
.toast b { color: var(--lime); }

/* ============================================================
   スマートフォン・タブレット（1カラム＋ボトムシート）
   ============================================================ */
@media (max-width: 959px) {
  .layout { grid-template-columns: 1fr; padding: 18px 16px 40px; gap: 0; }
  .topbar { padding: 0 16px; }

  .code-card, .code-locked { max-width: none; }

  .tiles-hero { grid-template-columns: 1fr; gap: 10px; }
  .tiles-hero .tile { flex-direction: row; align-items: center; min-height: 76px; padding: 12px 14px; }
  .tiles-hero .t-arrow { position: static; margin-left: auto; }
  .tiles-hero .tile-featured { padding: 18px 16px; }
  .tiles-hero .tile-featured .t-emoji { width: 54px; height: 54px; font-size: 28px; }
  .tiles-hero .tile-featured .t-name { font-size: 21px; }

  /* 右パネル → 全画面ボトムシート */
  .col-right {
    position: fixed; inset: 0; top: 0; z-index: 50;
    height: 100%; border: 0; border-radius: 0; box-shadow: none;
    transform: translateY(100%); visibility: hidden;
    transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s;
  }
  body.sheet-open { overflow: hidden; }
  body.sheet-open .col-right { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
  .col-right .panel-empty { display: none !important; }

  .sheet-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
    border-bottom: 1px solid var(--line); background: var(--paper);
  }
  .sheet-back { border: 0; background: none; font-weight: 800; font-size: 15px; padding: 6px 4px; }
  .sheet-code { font-family: var(--mono); font-weight: 800; font-size: 14px; background: var(--ink); color: var(--lime); padding: 3px 10px; border-radius: 999px; }

  .panel-head { padding: 14px 16px 10px; }
  .panel-title h2 { font-size: 20px; }
  .panel-desc { font-size: 13px; }
  .prompt-box { margin: 12px 12px 0; }
  .prompt-text { font-size: 13.5px; }

  .actions {
    grid-template-columns: 1fr; gap: 8px;
    padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px);
    background: var(--paper); border-top: 1px solid var(--line);
  }
  .actions button { min-height: 56px; font-size: 17px; }
  .btn-gpt { order: -1; }
  .toast { bottom: calc(env(safe-area-inset-bottom) + 150px); }
}

@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { flex-direction: column; align-items: flex-start; gap: 6px; min-height: 96px; padding: 12px; }
  .t-emoji { width: 36px; height: 36px; font-size: 19px; }
  .t-name { font-size: 14.5px; }
  .t-short { font-size: 11px; }
  .code-row input { font-size: 30px; letter-spacing: .14em; }
  .locked-main strong { font-size: 36px; }
  .brand-text { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
