/*
 * account.const-room.com の全画面に共通の見た目（platform-core#476）。
 *
 * Pages Functions が返す HTML から `<link rel="stylesheet" href="/ui.css">` で読む
 * （`server/page-chrome.ts` の `PAGE_HEAD_ASSETS`）。`public/` に置くのは、Vite がここの
 * ファイルを名前を変えずに `dist/` へ複製し、Cloudflare Pages が静的配信するため
 * （`index.html` が読む `/src/style.css` はビルド時にハッシュ付きの名前へ変わるので、
 * Functions からは参照できない）。インラインの <style> を使わないので、CSP に足すのは
 * `style-src 'self'` だけで済む（`unsafe-inline` は要らない）。
 *
 * 色は const-room.com（VK テーマ）に合わせる。黄色（#fcb900）の上は白ではなく濃い文字にする
 * （白文字は WCAG AA のコントラストに届かない）。外部のフォントは読まない（CSP が許さない）。
 *
 * ロゴは暗い背景で読めないため、ダークモードには追従しない（`color-scheme: light`）。
 */

:root {
  color-scheme: light;
  --brand: #fcb900;
  --brand-hover: #ffcc00;
  --brand-strong: #ca9400;
  --ink: #1f2328;
  --muted: #5b616b;
  --border: #dcdfe4;
  --surface: #ffffff;
  --page: #f6f5f1;
  --danger: #b42318;
  --danger-surface: #fef3f2;
  --info-surface: #fff8e1;
  --radius: 0.5rem;
  font-family: system-ui, -apple-system, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', Meiryo,
    sans-serif;
  color: var(--ink);
  background: var(--page);
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.7;
  background: var(--page);
  border-top: 4px solid var(--brand);
}

/* ---- ヘッダー・フッター（server/page-chrome.ts） ---- */

.site-header {
  padding: 1.25rem 1rem 0;
  text-align: center;
}

.site-header img {
  display: inline-block;
  width: 190px;
  height: auto;
  vertical-align: middle;
}

.site-header .site-sub {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.site-footer {
  margin-top: auto;
  padding: 1.5rem 1rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.25rem;
  margin: 0 0 0.5rem;
  padding: 0;
  list-style: none;
}

.site-footer a {
  color: var(--muted);
}

.site-footer small {
  font-size: inherit;
}

/* ---- 本文（カード） ---- */

main {
  width: calc(100% - 2rem);
  max-width: 34rem;
  margin: 1.5rem auto;
  padding: 1.75rem 1.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(16 24 40 / 6%);
}

/* 運用管理（/admin）の一覧は表が横に広いので、幅を広げる。 */
main.wide {
  max-width: 64rem;
}

@media (max-width: 30rem) {
  main {
    width: 100%;
    margin-block: 1rem;
    border-inline: 0;
    border-radius: 0;
  }
}

h1 {
  font-size: 1.35rem;
  line-height: 1.4;
  margin-block: 0 1.25rem;
}

h2 {
  font-size: 1.05rem;
  margin-block: 1.75rem 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1rem;
  margin-block: 1.25rem 0.5rem;
}

p {
  margin-block: 0 1rem;
}

a {
  color: #8a5a00;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--ink);
}

ul,
ol {
  padding-left: 1.25rem;
}

dt {
  font-weight: 600;
}

dd {
  margin: 0 0 0.75rem;
}

/* ---- フォーム ---- */

form {
  margin-block: 0 1rem;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

input[type='email'],
input[type='password'],
input[type='text'],
input[type='search'],
input[type='number'],
input[type='tel'],
input:not([type]),
select,
textarea {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #b8bdc5;
  border-radius: 0.375rem;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

button {
  padding: 0.7rem 1.25rem;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--brand);
  border: 1px solid var(--brand-strong);
  border-radius: 0.375rem;
  cursor: pointer;
}

button:hover {
  background: var(--brand-hover);
}

/* 主ボタン以外（拒否・取り消し等）は控えめに見せる。 */
button.secondary {
  background: transparent;
  border-color: #b8bdc5;
}

button.secondary:hover {
  background: #f0f1f3;
}

/* 送信中（`public/submit-guard.js`）。押せないことが見た目でも分かるようにする。 */
button:disabled,
button[aria-disabled='true'] {
  opacity: 0.6;
  cursor: progress;
}

/* ログイン等の主操作は横幅いっぱいにして押しやすくする。 */
form[data-submit-guard] > p > button[type='submit'],
.actions button {
  width: 100%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.actions button {
  flex: 1 1 10rem;
}

/* ---- 表（運用管理） ---- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-block: 0 1rem;
}

th,
td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f1f3;
}

/* ---- 文言の種類 ---- */

.note,
.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.error,
.warning {
  padding: 0.65rem 0.85rem;
  color: var(--danger);
  background: var(--danger-surface);
  border: 1px solid #fecdca;
  border-radius: 0.375rem;
}

.notice,
.flash {
  padding: 0.65rem 0.85rem;
  background: var(--info-surface);
  border: 1px solid #ffe08a;
  border-radius: 0.375rem;
}

.submit-status {
  margin-block: 1rem 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  word-break: break-all;
}

p > code:only-child {
  display: block;
  padding: 0.5rem 0.75rem;
  background: #f6f7f9;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}

/* ---- 同意画面（server/consent-view.ts） ---- */

.lead {
  margin-block: 0 1rem;
}

.scopes {
  margin: 0;
}

.scopes li {
  margin-block: 0.35rem;
}

.scope-id {
  color: var(--muted);
  font-size: 0.85em;
  word-break: break-all;
}

.redirect-uri {
  margin-block: 0 0.5rem;
}
