/* 占星術師AI — 鑑定登録サイト（スマホ・PC 両対応） */

:root {
  --bg: #f6f4fb;
  --surface: #ffffff;
  --text: #24203a;
  --muted: #6c6785;
  --border: #dcd7ea;
  --primary: #5b4bc4;
  --primary-text: #ffffff;
  --primary-soft: #ece9fb;
  --danger: #c0392b;
  --warn-bg: #fff6e0;
  --warn-border: #f0cf7a;
  --ok: #1e8a5a;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(40, 30, 90, 0.08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131f;
    --surface: #211e30;
    --text: #ebe8f7;
    --muted: #a6a1bf;
    --border: #3a3550;
    --primary: #8a7cf0;
    --primary-text: #15131f;
    --primary-soft: #2c2748;
    --danger: #ff7b6e;
    --warn-bg: #3a3020;
    --warn-border: #7a6430;
    --ok: #5fd39c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px; /* iPhone で入力時に拡大されないよう 16px 以上 */
  line-height: 1.7;
}

h1, h2, h3 { line-height: 1.4; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error-text { color: var(--danger); margin: 0.75rem 0 0; }

/* ── レイアウト ── */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
#app { max-width: 760px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card form { text-align: left; margin-top: 1rem; }
.brand { font-size: 2rem; color: var(--primary); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 6px; gap: 8px;
}
.topbar-title { font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }

.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 4px; padding: 8px 0 12px;
  background: var(--bg);
}
.tab {
  flex: 1; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 10px 6px; font-size: 0.92rem; cursor: pointer;
}
.tab.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 700; }
.badge { font-size: 0.75rem; opacity: 0.85; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; gap: 0; } }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.actions .btn-large { flex: 1 1 220px; }

/* ── フォーム ── */
label, .field-label { display: block; font-size: 0.9rem; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 6em; }
#paste-input { min-height: 40vh; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }

.segmented { border: 0; padding: 0; margin: 12px 0; display: flex; gap: 8px; flex-wrap: wrap; }
.segmented legend { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; padding: 0; }
.segmented label {
  margin: 0; font-weight: 400; flex: 1; text-align: center; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.segmented label:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); font-weight: 700; }
.segmented input { margin-right: 6px; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 16px; }
.check input { width: 20px; height: 20px; }

.birth-form { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.birth-title { margin: 0; color: var(--primary); }

/* ── ボタン ── */
.btn {
  font: inherit; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 18px; cursor: pointer; min-height: 44px;
}
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--primary); color: var(--primary-text); font-weight: 700; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; margin-top: 16px; }
.btn-large { font-size: 1.05rem; padding: 14px 18px; }
.btn-small { min-height: 34px; padding: 4px 12px; font-size: 0.85rem; }

/* ── お知らせ・プレビュー ── */
.notice { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 10px; padding: 10px 14px; font-size: 0.92rem; }
.notice ul { margin: 0; padding-left: 1.2em; }
.preview { margin-top: 10px; }
.preview summary { cursor: pointer; color: var(--primary); font-size: 0.9rem; }
.preview-text { white-space: pre-wrap; word-break: break-word; background: var(--bg); border-radius: 10px; padding: 12px; margin-top: 8px; max-height: 50vh; overflow: auto; }

.done-card { text-align: center; }
.done-icon { font-size: 2.6rem; }

/* ── 一覧 ── */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; text-align: left; font: inherit; color: inherit; cursor: pointer; width: 100%;
}
.item-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.item-title { font-weight: 700; margin: 2px 0; }
.item-preview { font-size: 0.9rem; color: var(--muted); }
.tag { display: inline-block; font-size: 0.75rem; border-radius: 6px; padding: 0 6px; background: var(--primary-soft); color: var(--primary); margin-left: 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ── 対話 ── */
.chat-messages { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; padding: 8px 0; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.msg.astrologer { align-self: flex-end; background: var(--primary-soft); }
.msg.ai { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); }
.msg .fb-link { display: block; margin-top: 6px; font-size: 0.8rem; color: var(--primary); background: none; border: 0; padding: 0; cursor: pointer; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.chat-input textarea { min-height: 3em; }

/* ── ダイアログ・通知 ── */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(680px, calc(100vw - 24px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(10, 8, 25, 0.55); }
.dialog-body { padding: 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  transition: transform 0.25s ease, visibility 0.25s; max-width: calc(100vw - 32px); z-index: 20; font-size: 0.92rem;
  visibility: hidden;
}
.toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
.toast.error { background: var(--danger); color: #fff; }
#done-summary { white-space: pre-line; }
