/* style.css — StackNote（StackWorld ダークテーマ準拠） */

:root{
  color-scheme: dark;
  --bg0:#070a12;
  --bg1:#0b1220;
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.62);
  --card:rgba(2,6,23,.55);
  --border:rgba(255,255,255,.10);
  --accent:rgba(129,140,248,.9);
  --accent-bg:rgba(99,102,241,.18);
  --ok:#34d399;
  --ng:#fb923c;
}
*{ box-sizing:border-box; }
/* .btn等のdisplay指定がUAの[hidden]を上書きしないよう明示（hidden属性を常に有効化） */
[hidden]{ display:none !important; }
html,body{ height:100%; }
body{
  margin:0;
  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);
  background:
    radial-gradient(1200px 800px at 10% 0%, rgba(111,123,255,.12), transparent 55%),
    radial-gradient(900px 700px at 90% 10%, rgba(236,72,153,.10), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.page{ min-height:100%; padding:16px; display:flex; justify-content:center; }

/* グローバルエラーバナー（config読込失敗・予期せぬ例外時） */
.error-banner{
  position:fixed; inset:0 0 auto 0; z-index:1000;
  margin:0; padding:12px 16px;
  background:rgba(127,29,29,.96);
  color:#fff; font-size:13px; font-weight:700;
  text-align:center;
  box-shadow:0 6px 20px rgba(0,0,0,.5);
}
.shell{
  width:min(960px,100%);
  border-radius:24px;
  background:rgba(15,23,42,.94);
  box-shadow:0 30px 80px rgba(0,0,0,.9), 0 0 0 1px rgba(148,163,184,.2);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

/* ---------- header ---------- */
.header{
  padding:16px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  border-bottom:1px solid rgba(255,255,255,.08);
  background:rgba(2,6,23,.35);
  user-select:none;
}
.header-left{ display:flex; align-items:center; gap:12px; }
.logo-orb{
  width:40px; height:40px; border-radius:999px;
  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%, #0ea5e9, 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:2px; }
.logo-main{ font-size:18px; letter-spacing:.18em; font-weight:900; margin:0; }
.logo-sub{ font-size:11px; opacity:.75; }
.header-right{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }

/* ---------- 共通パーツ ---------- */
.pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 12px; border-radius:999px; font-size:12px;
  background:rgba(15,23,42,.85);
  border:1px solid rgba(148,163,184,.55);
  white-space:nowrap;
}
.pill strong{ font-weight:900; }
.muted{ color:var(--muted); }
.ok{ color:var(--ok); font-weight:900; }
.ng{ color:var(--ng); font-weight:900; }

.btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding:8px 14px; border-radius:999px;
  font-size:12px; font-weight:900;
  border:1px solid var(--accent);
  background:var(--accent-bg);
  color:#fff; cursor:pointer; text-decoration:none;
  transition:transform .08s ease-out, filter .08s ease-out;
  white-space:nowrap;
}
.btn:hover{ transform:translateY(-1px); filter:brightness(1.05); }
.btn:disabled{ opacity:.55; cursor:not-allowed; transform:none; }
.btn-ghost{ background:rgba(15,23,42,.75); border-color:rgba(148,163,184,.55); }
.btn-big{ padding:12px 22px; font-size:13px; }

.chips{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.chip{
  display:inline-flex; align-items:center; justify-content:center;
  padding:8px 12px; border-radius:999px;
  font-size:11px; font-weight:900; cursor:pointer; user-select:none;
  background:rgba(15,23,42,.75);
  border:1px solid rgba(148,163,184,.55);
  color:#e5e7eb;
}
.chip.is-on{ border-color:rgba(129,140,248,.95); background:rgba(99,102,241,.20); color:#fff; }

/* ---------- main ---------- */
.content{ padding:16px 18px 18px; display:flex; flex-direction:column; gap:14px; }
.card{
  border:1px solid var(--border);
  background:var(--card);
  border-radius:16px;
  padding:14px;
}
.card-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.card-title{ margin:0 0 8px; font-size:14px; font-weight:900; letter-spacing:.08em; }
.lines{ font-size:12px; color:rgba(255,255,255,.80); line-height:1.8; margin:0 0 8px; }
#login-card-msg{ white-space:pre-line; } /* JSが\n付きで文言を入れるため */
.actions{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-top:10px; }
.msg{ font-size:12px; color:var(--ng); margin:8px 0 0; min-height:1em; }
.msg.ok{ color:var(--ok); }
.msg.muted{ color:var(--muted); } /* 進行中メッセージはエラー色にしない */

/* ---------- form ---------- */
.field{ display:flex; flex-direction:column; gap:6px; margin:0 0 12px; border:0; padding:0; min-width:0; }
fieldset.field{ margin-inline:0; }
.field-label{ font-size:12px; font-weight:900; color:rgba(255,255,255,.85); }
.field-counter{ align-self:flex-end; font-size:11px; color:var(--muted); }
.field-counter.over{ color:var(--ng); font-weight:900; }
.field-row{ display:flex; gap:10px; flex-wrap:wrap; }
.field-row .field{ flex:1 1 160px; }
textarea, select{
  width:100%;
  font:inherit; font-size:13px;
  color:var(--text);
  background:rgba(2,6,23,.45);
  border:1px solid rgba(148,163,184,.35);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
}
textarea{ resize:vertical; line-height:1.7; }
textarea:focus, select:focus{ border-color:rgba(129,140,248,.8); }

.radio-row{ display:flex; gap:8px; flex-wrap:wrap; }
.radio-pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:9px 12px; border-radius:999px;
  font-size:12px; cursor:pointer; user-select:none;
  background:rgba(15,23,42,.75);
  border:1px solid rgba(148,163,184,.55);
}
.radio-pill b{ margin-left:4px; color:#a5b4fc; }
.radio-pill:has(input:checked){
  border-color:rgba(129,140,248,.95);
  background:rgba(99,102,241,.20);
}
.radio-pill input{ accent-color:#818cf8; }

/* ---------- 結果 ---------- */
.result-box{
  border:1px solid rgba(255,255,255,.12);
  background:rgba(2,6,23,.45);
  border-radius:12px;
  padding:12px;
  max-height:480px;
  overflow:auto;
}
.result-box pre{
  margin:0;
  font:inherit;
  font-size:13px;
  line-height:1.85;
  white-space:pre-wrap;
  word-break:break-word;
}

/* ---------- 履歴 ---------- */
.count-badge{ font-size:11px; font-weight:700; color:var(--muted); letter-spacing:0; }
.search-box{ margin:8px 0 0; }
.search-box input{
  width:100%; font:inherit; font-size:13px; color:var(--text);
  background:rgba(2,6,23,.45); border:1px solid rgba(148,163,184,.35);
  border-radius:999px; padding:8px 14px; outline:none;
}
.search-box input:focus{ border-color:rgba(129,140,248,.8); }
.undo-link{
  margin-left:8px; background:none; border:0; padding:0; cursor:pointer;
  color:#93c5fd; font:inherit; font-size:12px; font-weight:900; text-decoration:underline;
}
.history-list{ list-style:none; margin:8px 0 0; padding:0; display:flex; flex-direction:column; gap:8px; }
.history-item{
  border:1px solid rgba(255,255,255,.10);
  background:rgba(15,23,42,.55);
  border-radius:12px;
  padding:10px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}
.history-main{ min-width:0; flex:1 1 200px; }
.history-title{ font-size:13px; font-weight:900; margin:0 0 2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.history-meta{ font-size:11px; color:var(--muted); }
.history-actions{ display:flex; gap:6px; flex-wrap:wrap; }
.mini{
  display:inline-flex; align-items:center; justify-content:center;
  padding:7px 11px; border-radius:999px;
  font-size:11px; font-weight:900;
  background:rgba(15,23,42,.85);
  border:1px solid rgba(148,163,184,.55);
  color:#e5e7eb; cursor:pointer;
}
.mini:hover{ filter:brightness(1.05); }
.mini.danger{ border-color:rgba(248,113,113,.6); color:#fca5a5; }
.history-empty{ font-size:12px; color:var(--muted); padding:6px 2px; }

/* ---------- footer ---------- */
.footer-legal{
  padding:14px 18px;
  border-top:1px solid rgba(255,255,255,.08);
  background:rgba(2,6,23,.55);
  color:rgba(255,255,255,.70);
  font-size:12px;
  line-height:1.7;
}
.footer-links{ display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.footer-link{
  display:inline-flex; align-items:center; justify-content:center;
  padding:8px 12px; border-radius:999px;
  font-size:11px; font-weight:900;
  background:rgba(15,23,42,.85);
  border:1px solid rgba(148,163,184,.55);
  color:#e5e7eb; text-decoration:none; white-space:nowrap;
}

/* ---------- アクセシビリティ配慮 ---------- */
@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; animation:none !important; scroll-behavior:auto !important; }
  .btn:hover{ transform:none; }
}
@media (prefers-contrast: more){
  :root{ --muted:rgba(255,255,255,.85); --border:rgba(255,255,255,.4); }
  .pill, .chip, .mini, .btn-ghost, .footer-link, textarea, select, .radio-pill{ border-color:rgba(255,255,255,.6); }
}
@media (forced-colors: active){
  .btn, .chip, .mini, .pill, .footer-link, textarea, select, .radio-pill, .card, .result-box{ border:1px solid CanvasText; }
}

/* ---------- 印刷（記事本文だけを綺麗に出す） ---------- */
@media print{
  body{ background:#fff; color:#000; }
  .header, .footer-legal, #login-card, #gen-section, #history-section, .card-head .chips, .actions{ display:none !important; }
  .shell{ box-shadow:none; background:#fff; border-radius:0; }
  .card, .result-box{ border:0; background:#fff; }
  .result-box{ max-height:none; overflow:visible; }
  #result-text{ color:#000; }
}

/* ---------- スマホ ---------- */
@media (max-width:640px){
  .page{ padding:10px; }
  .content{ padding:12px; gap:10px; }
  .header{ padding:12px; }
  .header-right{ justify-content:flex-start; }
  /* iOS Safariのフォーカス時自動ズーム防止（16px未満だとズームされる） */
  textarea, select, .search-box input{ font-size:16px; }
  .field-row{ flex-direction:column; gap:0; }
  .radio-row{ flex-direction:column; }
  .radio-pill{ justify-content:space-between; }
  .btn-big{ width:100%; }
  .result-box{ max-height:60vh; }
  .legal-one-line{ white-space:normal; }
  .footer-links{
    flex-wrap:nowrap; overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    padding-bottom:2px;
  }
}
