/* ===========================================================================
   modern-dev-proposal — スタイル
   ---------------------------------------------------------------------------
   ビルド不要で動かすため、素のCSS（カスタムプロパティ + ネスト）で記述しています。
   ダークを基調に、カテゴリごとの情報量を整理して見せることを優先した設計です。
   =========================================================================== */

:root {
  /* 配色 */
  --bg: #0b0f14;
  --bg-elev: #121820;
  --bg-elev-2: #18202b;
  --line: #24303d;
  --line-strong: #33465a;
  --text: #e6edf3;
  --text-dim: #93a4b5;
  --text-faint: #64748b;

  --accent: #38bdf8; /* 選択・主要アクション */
  --accent-deep: #0ea5e9;
  --gold: #fbbf24; /* 定番バッジ */
  --lime: #a3e635; /* 有力バッジ */
  --violet: #c084fc; /* 用途特化バッジ */
  --danger: #f87171;

  /* 形状 */
  --radius: 10px;
  --radius-lg: 16px;
  --font: 'Hiragino Sans', 'Noto Sans JP', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* display を指定した要素でも hidden 属性を確実に効かせる */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 15px;
  /* 背景にごく薄いグリッドを敷いて「開発ツール」らしさを出す */
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
}

h1,
h2,
h3 {
  line-height: 1.4;
  margin: 0;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg-elev-2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  color: var(--accent);
}

/* --------------------------------------------------------------- レイアウト */

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: 0 -24px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  font-size: 28px;
  line-height: 1;
}

.brand__title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand__sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.app-header__actions {
  display: flex;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 32px;
  align-items: start;
  margin-top: 32px;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* ----------------------------------------------------------------- ガイド */

.guide {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 20px 24px;
}

.guide h2 {
  font-size: 16px;
  margin-bottom: 8px;
}

.guide h3 {
  font-size: 14px;
  margin: 18px 0 8px;
  color: var(--text-dim);
}

.guide__steps {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
}

.guide__legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.guide__note {
  font-size: 13px;
  color: var(--text-dim);
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

/* --------------------------------------------------------------- セクション */

.section {
  margin-bottom: 40px;
  scroll-margin-top: 90px;
}

.section__head {
  margin-bottom: 16px;
}

.section__title {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section__icon {
  font-size: 20px;
}

.section__count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}

.section__desc {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

/* 各カテゴリの「学び」ブロック */
.section__learn {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-dim);
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.07), transparent);
  border-left: 2px solid var(--accent-deep);
  padding: 10px 14px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.section__learn::before {
  content: '💡 ';
}

/* ------------------------------------------------------------- プリセット */

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.preset {
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  color: inherit;
  transition:
    border-color 0.15s,
    transform 0.15s,
    background 0.15s;
}

.preset:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.preset[aria-pressed='true'] {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.12), var(--bg-elev));
  box-shadow: 0 0 0 1px var(--accent);
}

.preset__top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.preset__icon {
  font-size: 20px;
}

.preset__name {
  font-weight: 700;
  font-size: 14px;
}

.preset__scale {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.preset__summary {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
}

.preset-reason {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 16px 18px;
  font-size: 13px;
}

.preset-reason h3 {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 6px;
}

.preset-reason p {
  margin: 0 0 8px;
  color: var(--text-dim);
}

.preset-reason p:last-child {
  margin-bottom: 0;
}

/* ------------------------------------------------------------- カード */

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.option {
  position: relative;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.option:hover:not(.option--disabled) {
  border-color: var(--line-strong);
  background: var(--bg-elev-2);
}

.option[aria-pressed='true'] {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.13), var(--bg-elev));
}

/* 選択済みのチェックマーク */
.option[aria-pressed='true']::after {
  content: '✓';
  position: absolute;
  top: -1px;
  right: -1px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--bg);
  background: var(--accent);
  border-radius: 0 var(--radius) 0 var(--radius);
}

.option--disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.option__head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.option__name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
}

.option__help {
  margin-left: auto;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  background: transparent;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.option__help:hover,
.option__help:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

/* 選択済みカードでも ✓ と重ならないよう少しずらす */
.option[aria-pressed='true'] .option__help {
  margin-right: 18px;
}

.option__tagline {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
  flex: 1;
}

.option__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.option__reason {
  font-size: 11px;
  color: var(--danger);
  border-top: 1px dashed var(--line);
  padding-top: 6px;
  margin: 0;
}

/* 排他の予告（選択を妨げるものではないので警告色にしない） */
.option__reason--swap {
  color: var(--text-faint);
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge--major {
  color: #3d2c00;
  background: var(--gold);
}

.badge--popular {
  color: #1f2d00;
  background: var(--lime);
}

.badge--niche {
  color: #2a0d45;
  background: var(--violet);
}

.tag {
  font-size: 10px;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 6px;
  white-space: nowrap;
}

/* ------------------------------------------------------------- サマリ */

.layout__side {
  position: sticky;
  top: 86px;
}

@media (max-width: 1080px) {
  .layout__side {
    position: static;
  }
}

.summary {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  padding: 20px;
}

.summary__title {
  font-size: 15px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field__label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.field__input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 13px;
}

.field__input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field__hint {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 4px;
}

.summary__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 4px;
}

.summary-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
  font-size: 12px;
  align-items: baseline;
}

.summary-row__label {
  color: var(--text-faint);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-row__value {
  color: var(--text);
  font-weight: 600;
}

.summary__empty {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  padding: 20px 0;
}

.summary__warn {
  margin-top: 14px;
  font-size: 12px;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.summary__actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary__actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.summary__note {
  margin: 14px 0 0;
  font-size: 10px;
  color: var(--text-faint);
  line-height: 1.6;
}

/* ------------------------------------------------------------- ボタン */

.btn {
  border: 1px solid var(--line-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  transition:
    background 0.15s,
    border-color 0.15s,
    opacity 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--line);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06212e;
}

.btn--primary:hover:not(:disabled) {
  background: #7dd3fc;
}

.btn--accent {
  background: transparent;
  border-color: var(--gold);
  color: var(--gold);
}

.btn--accent:hover:not(:disabled) {
  background: color-mix(in srgb, var(--gold) 14%, transparent);
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
  padding: 7px 12px;
}

.btn--ghost:hover {
  color: var(--text);
}

/* ------------------------------------------------------------ ツールチップ */

.tooltip {
  position: fixed;
  z-index: 60;
  max-width: 340px;
  background: #0a0e13;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.tooltip__title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--accent);
}

.tooltip__body {
  color: var(--text-dim);
}

.tooltip__docs {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 11px;
  color: var(--text-faint);
  word-break: break-all;
}

/* ---------------------------------------------------------------- モーダル */

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
}

.modal__panel {
  position: relative;
  width: min(920px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.modal__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal__title {
  font-size: 15px;
}

.modal__close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal__close:hover {
  color: var(--text);
  background: var(--bg-elev-2);
}

.modal__body {
  padding: 20px;
  overflow: auto;
}

.modal__foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal__lead {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 14px;
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cbd5e1;
  margin: 0;
  max-height: 52vh;
  overflow: auto;
}

.file-tree {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.9;
  margin: 0;
}

.file-tree__item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 2px 6px;
  border-radius: 4px;
}

.file-tree__item:hover {
  background: var(--bg-elev-2);
}

.file-tree__path {
  color: var(--text);
}

.file-tree__note {
  margin-left: auto;
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-faint);
}

/* ------------------------------------------------------------------ トースト */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--accent);
  color: #06212e;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

/* ------------------------------------------------------- モバイル操作バー */

.mobile-bar {
  display: none;
}

@media (max-width: 1080px) {
  .mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 8px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }

  /* 固定バーに隠れないよう余白を確保する */
  .app {
    padding-bottom: 110px;
  }
}

/* ------------------------------------------------------------------ フッター */

.app-footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
}

/* アニメーションを抑制する設定を尊重する */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
