/* 数秘術チャート デザインシステムの基礎スタイル。
   アプリ本体のスタイルはこれを土台に拡張する（このファイルに追記するか、
   別ファイルを新設して base.html / app.html から読み込む）。 */

:root {
  --bg: #17171c;
  --surface: #201f27;
  --surface-2: #2a2933;
  --border: #38363f;
  --text: #f0eef5;
  --text-muted: #a19eae;
  --accent: #8b5cf6;
  --accent-hover: #9d70ff;
  --accent-text: #ffffff;
  --danger: #ef4444;
  --danger-hover: #f65f5f;
  --radius: 10px;
  /* マスター／カルマナンバー（11・22・13・14・16・19）の強調と、ブランドマークの星に
     使う金色。legacy の --gold-soft を踏襲。 */
  --gold: #f2d98a;
  /* ブランドマークの鉛筆の先の色。static/logo-mark.svg のプレースホルダーに対応する
     値。マークを描き直したら、ここも実測値に合わせること。 */
  --logo-tip: #ffdc78;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--accent);
}

/* ブランドマーク（templates/_logo-mark.html）。ヘッダーと静的ページで共有するので
   ここに置く。favicon.png と同じ意匠にしてある（static/logo-mark.svg が唯一の正）。 */
.logo-mark {
  display: block;
  width: 28px;
  height: 28px;
}

.logo-mark__plate {
  fill: var(--accent);
  transition: fill 0.15s ease;
}

.logo-mark__star {
  fill: var(--gold);
}

/* ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

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

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

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

/* トースト（shared/ui.js） */
.toast-container {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.92rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: min(90vw, 480px);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success { border-color: var(--accent); }
.toast--error { border-color: var(--danger); }

/* モーダル（shared/ui.js） */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: min(92vw, 640px);
  max-height: 86dvh;
  overflow: auto;
}

.modal-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.modal-message {
  margin: 0 0 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* アプリ本体の入口（templates/app.html の #app-root）。 */
#app-root {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.app-lead {
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* 星空の背景演出（static/js/starfield.js）。#app-root より背面に固定する
   （#app-root 側の position: relative; z-index: 1; で重なり順を確保している）。 */
.constellation {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

/* 入力フォーム・結果表示の各セクション（旧 .panel）。既存の surface トークンに合わせる。 */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px clamp(16px, 4vw, 32px);
  margin-bottom: 24px;
}

.panel h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold);
  margin: 0 0 18px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}

.field {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field--small {
  flex: 0 1 100px;
}

.field label {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.field input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.field input::placeholder {
  color: var(--text-muted);
}

.field input:focus {
  border-color: var(--accent);
}

.btn-row {
  display: flex;
  justify-content: center;
  margin: 8px 0 4px;
}

/* 9つの数の結果 */
.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 6px;
}

.result-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
}

.result-line:last-child {
  border-bottom: none;
}

.result-line-wrap .result-line {
  border-bottom: none;
  padding-bottom: 2px;
}

.result-line-wrap {
  border-bottom: 1px solid var(--border);
}

.result-line-wrap:last-child {
  border-bottom: none;
}

.frozen-note {
  font-size: 0.7rem;
  color: var(--gold);
  opacity: 0.85;
  padding: 0 4px 12px;
}

.result-label span {
  font-size: 0.9rem;
}

.result-label small {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.result-value {
  font-weight: 600;
  font-size: 1.5rem;
  min-width: 56px;
  text-align: right;
  white-space: nowrap;
}

.result-value.master {
  color: var(--gold);
  text-shadow: 0 0 14px rgba(242, 217, 138, 0.45);
}

.note {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 12px 0 0;
}

.note--tight {
  margin-top: -8px;
  margin-bottom: 4px;
}

/* 特性数・欠落数 */
.digit-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.digit-cell {
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 2px;
  background: var(--surface-2);
}

.digit-cell .n {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.digit-cell .c {
  font-size: 1.15rem;
  color: var(--gold);
  margin-top: 4px;
}

.missing {
  margin-top: 12px;
  font-size: 0.85rem;
}

.missing .m-nums {
  color: var(--gold);
  letter-spacing: 0.06em;
}

/* 気質のバランス */
.balance-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 8px;
}

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

.balance-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface-2);
}

.balance-card .t {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.balance-card .v {
  font-size: 1.35rem;
  color: var(--gold);
}

/* 四つの時期 */
.table-scroll {
  overflow-x: auto;
}

.periods-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.9rem;
}

.periods-table th,
.periods-table td {
  border: 1px solid var(--border);
  padding: 10px 8px;
  text-align: center;
  white-space: nowrap;
}

.periods-table th {
  color: var(--gold);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.periods-table td.master {
  color: var(--gold);
  font-weight: 700;
}
