
.download fieldset, .login fieldset{
  display: flex;
  text-align: center;
}
.download fieldset table, .login fieldset table {
   flex: 1;
}



/* ==========================================================================
   Summary

   0 = Design tokens (ラックプラスポータル準拠)
   1 = Basic Style
   2 = Copyright
   3 = Options
   4 = Upload
   5 = Terms of service
   6 = Install
   7 = Admin
   8 = Download page

   ========================================================================== */

/* ==========================================================================
   0 = Design tokens

   ポータル圏デザイン仕様（docs/design-spec-portal-ring.md）の実測値。
   :root = ライト / html.dark = 全トークン上書き の 2 段構え（ポータルと同一機構）。
   ここに無い色は新しく持ち込まない。値の正本は
   luckplus-portal/frontend/app/globals.css の :root と html.dark。

   ファイル便には切替ボタンを置かない（OS 設定の自動追従のみ）。
   ただし html.dark という掛かり口自体は正しく効く必要がある
   （手で html に dark を付けたらダークで描画される）。
   ========================================================================== */

:root {
  /* 面 */
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --foreground: #020617;
  --foreground-muted: #475569;
  --foreground-subtle: #64748b;

  /* ブランド・操作 */
  --primary: #0f172a;
  --on-primary: #ffffff;
  --accent: #0369a1;
  --accent-hover: #075985;
  --accent-soft: #e0f2fe;
  --ring: #0284c7;  /* 2026-08-18: 旧 #0ea5e9 はライト背景で 2.65:1 とフォーカス視認基準(3:1)未達 — #0284c7=3.91:1 へ（ダークは #38bdf8 のまま） */

  /* 罫線 */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* 意味色 */
  --success: #15803d;
  --warning: #b45309;
  --destructive: #dc2626;
  --info: #0369a1;

  /* 字体・角丸・影 */
  --font-sans: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono", monospace;
  --radius-card: 8px;
  --radius-control: 6px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .05);
}

/* ダーク（ポータル html.dark の実測値を逐語）。
   意味色（成功/警告/破壊/情報）もここでダーク変種に差し替わるので、
   別建ての機能色ブロックは不要。 */
html.dark {
  /* 面 */
  --background: #0b1220;
  --surface: #111827;
  --surface-muted: #1f2937;
  --foreground: #f1f5f9;
  --foreground-muted: #cbd5e1;
  --foreground-subtle: #94a3b8;

  /* ブランド・操作 */
  --primary: #f1f5f9;
  --on-primary: #0b1220;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-soft: #0c4a6e;
  --ring: #38bdf8;

  /* 罫線 */
  --border: #334155;
  --border-strong: #475569;

  /* 意味色 */
  --success: #4ade80;
  --warning: #fbbf24;
  --destructive: #f87171;
  --info: #38bdf8;

  /* 影は暗い面の上では 5% だと消えるので濃度だけ上げる（色は増やさない） */
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .45);
}

/* ネイティブ UI（input・select・スクロールバー）をテーマに追従させる */
html { color-scheme: light; }
html.dark { color-scheme: dark; }

/* ==========================================================================
   1 = Basic Style
   ========================================================================== */

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  margin: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* キーボード操作時のフォーカスリング（消さない） */
*:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

#content {
  padding: 2em;
}

h1 a {
  display: block;
  background: url(logo-jirafeau.svg) no-repeat;
  background-size: 100% 100%;
  text-indent: -9999px;
  width: 194px;
  height: 185px;
  margin: 1em auto;
  position: relative;
  left: 0.4em;
}

/* ロゴは「黒の面 + ブランド赤の面」の 2 色。黒の面はダーク背景では
   ほぼ見えなくなる（黒 対 #0b1220 で約 1.1:1）ため、ダークでは黒を
   --foreground 相当（#f1f5f9）に差し替えた派生 SVG を使う。
   赤はブランド色なので両テーマとも変えない。
   ※ logo-jirafeau.svg を差し替えたら logo-jirafeau-dark.svg も同時に作り直すこと
     （中身は fill="#000000" → fill="#f1f5f9" の 1 箇所違いだけ）。 */
html.dark h1 a {
  background-image: url(logo-jirafeau-dark.svg);
}

h2 {
  text-align: center;
  color: var(--foreground);
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

a:hover,
a:focus {
  color: var(--accent-hover);
}

/* リンク文字列やバグ報告の貼り付け用 <code>。ブラウザ既定のままだと
   等幅になるだけで面が無く、ダークでは地の色を持たないので明示的に
   トークンで面と文字を与える（長い URL は折り返す）。 */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-muted);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 0.15em 0.4em;
  word-break: break-all;
}

fieldset {
  padding: 1.5em;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  width: 20em;
  min-height: 15em;
  min-width: 30em;
  position: relative;
}

/* legend は fieldset の枠線の上にまたがって座る。背景パッチが「ただの四角」に
   見えていた（Alex 2026-08-18）ので、枠 + 角丸を付けて意図した「タグ」に見せる。 */
legend {
  padding: 0.35em 1em;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  color: var(--foreground);
  font-size: 1.05em;
  font-weight: 600;
  display: block;
  min-width: 0;
  text-align: center;
}

table a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

table a:hover,
table a:focus {
  color: var(--accent-hover);
}

/* 主ボタン: --primary 地 + 白字 */
input[type="submit"] {
  background: var(--primary);
  color: var(--on-primary);
  border: 0;
  border-radius: var(--radius-control);
  padding: 0.65em 1.8em;
  min-height: 44px;
  font-family: inherit;
  font-size: 1em;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  margin: 10px;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease;
}

/* 二次ボタン: --surface 地 + 枠線（リンクコピー等） */
button {
  background: var(--surface);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 0.35em 0.7em;
  font-family: inherit;
  font-size: 1em;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

button:hover,
button:focus {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

select,
input[type="text"],
input[type="password"] {
  background: var(--surface);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 0.45em 0.6em;
  font-family: inherit;
  font-size: 1em;
}

select:hover,
input[type="text"]:hover,
input[type="password"]:hover {
  border-color: var(--border-strong);
}

select { width: 100%; }

/* hover は色の変化のみ（レイアウトは動かさない）。hover 先はリザープラスと統一（--accent-hover） */
input[type="submit"]:hover,
input[type="submit"]:focus {
  background: var(--accent-hover);
}

input[type="submit"]:disabled,
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.inner {
  margin-top: 3em;
}

/* ドロップゾーン。破線の枠がこの面の唯一の目印なので、罫線トークンではなく
   --foreground-subtle（中のアイコンと同じ濃さ）を使い、両テーマで
   非文字の 3:1 を満たす（--border-strong だと light 1.48 / dark 2.34 で足りない）。 */
#upload fieldset {
  background: var(--surface) url(upload.svg) no-repeat center;
  border: 2px dashed var(--foreground-subtle);
  -webkit-transition: border-color 0.25s ease, background-color 0.25s ease;
     -moz-transition: border-color 0.25s ease, background-color 0.25s ease;
      -ms-transition: border-color 0.25s ease, background-color 0.25s ease;
       -o-transition: border-color 0.25s ease, background-color 0.25s ease;
          transition: border-color 0.25s ease, background-color 0.25s ease;
}

#upload fieldset:hover {
  border-color: var(--accent);
  background-color: var(--accent-soft);
}

#upload > form {
  text-align: center;
}

#upload p {
  margin: 0;
}

#file_select {
  position: relative;
  width: 100%;
  height: 16em;
  cursor: pointer;
  opacity: 0;
}
  #upload.file-selected #file_select {
    opacity: 1;
    height: 2em;
  }
  #upload.file-selected fieldset {
    background-image: none;
  }


/* ==========================================================================
   2 = Copyright
   ========================================================================== */

#copyright {
  text-align: center;
  font-size: 0.8em;
  color: var(--foreground-subtle);
  margin: 3em auto;
}

#copyright a {
  color: var(--foreground-subtle);
  text-decoration: none;
}

#copyright a:hover,
#copyright a:focus {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ==========================================================================
   3 = Options
   ========================================================================== */

/* アップロードのオプション表（ダウンロードは一回のみ / パスワード / 有効期限）。
   旧: tr:first-child に width/height 100% が掛かっていてラベル列が最小幅まで潰れ、
   1 文字ずつ縦に折れていた（Alex 2026-08-18）。素直な 2 列のフォーム表に戻す。 */
#options {
  position: relative;
  z-index: 10;
  width: 100%;
}

#option_table {
  margin: 0 auto;
  border-collapse: collapse;
}

#option_table td {
  padding: 0.45em 0.5em;
  text-align: left;
  vertical-align: middle;
}

#option_table td:first-child {
  white-space: nowrap;
  text-align: right;
  color: var(--foreground-muted);
}

#options input[type="submit"] {
  position: relative;
  margin: 1em auto;
}

/* ==========================================================================
   4 = Upload
   ========================================================================== */

#upload_finished,
#uploading,
.message,
.info,
.error {
  text-align: center;
  color: var(--foreground-muted);
  padding-left: 3em;
}

#upload_finished > p:nth-child(1) {
  color: var(--success);
  font-weight: bold;
}

#upload_finished div p:nth-child(1) {
  font-weight: bold;
}

#upload_finished a {
  text-decoration: none;
  color: var(--accent);
}

#uploading a {
  font-weight: bold;
  text-decoration: none;
  color: var(--accent);
}

#uploaded_percentage {
  font-size: 2em;
  font-weight: bold;
  color: var(--foreground);
}

#upload_finished a:hover,
#uploading a:hover,
#upload_finished a:focus,
#uploading a:focus {
  color: var(--accent-hover);
  text-decoration: underline;
}

.message,
.error {
  color: var(--destructive);
  font-style: italic;
  font-weight: bold;
}

#upload_link_email {
  margin-left: 10px;
}

#upload_image_email {
  padding-left: 20px;
  padding-bottom: 15px;
  background: url(email.png) no-repeat;
}

/* 目（表示切替）は入力欄の右端「内側」に重ねる。旧: td の右端に絶対配置
   されていて、入力欄の外（点線枠の上）に浮いて見えた（Alex 2026-08-18）。 */
#show_password {
  position: absolute;
  right: 0.95em; /* td 自身の右パディング 0.5em の分だけ深く入れて入力欄の内側に落とす */
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 30%;
}
#show_password:hover {
  opacity: 100%;
}

/* 目のアイコンの「斜線」だけ SVG 側に stroke="#000" が直書きされていて
   ダークでは消える。文字色（= トークン）に追従させる。 */
#show_password svg path,
#show_password svg circle {
  stroke: currentColor;
}

.passwordcolumn {
  display: flex;
  position: relative;
  align-items: center;
  width: 100%;
}

/* 入力欄がセルいっぱいに広がることで、上の絶対配置が「入力欄の内側」に落ちる。
   目と文字が重ならないよう右パディングで逃がす。 */
.passwordcolumn input[type="password"],
.passwordcolumn input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  box-sizing: border-box;
  padding-right: 2.1em;
}

/* ==========================================================================
   5 = Terms of service
   ========================================================================== */

textarea[readonly="readonly"] {
  border: 0;
  color: var(--foreground-muted);
  font-family: var(--font-sans);
  font-size: 1em;
  line-height: 1.5;
  background: none;
  margin: auto;
  display: block;
}

textarea[readonly="readonly"] + p,
textarea[readonly="readonly"] + p + p {
  text-align: center;
  color: var(--foreground-muted);
}

textarea[readonly="readonly"] + p a,
textarea[readonly="readonly"] + p + p a {
  font-weight: bold;
  text-decoration: none;
  color: var(--accent);
}

textarea[readonly="readonly"] + p a:hover,
textarea[readonly="readonly"] + p + p a:hover,
textarea[readonly="readonly"] + p a:focus,
textarea[readonly="readonly"] + p + p a:focus {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ==========================================================================
   6 = Install
   ========================================================================== */

#install fieldset,
#install + fieldset {
  width: auto;
  max-width: 50em;
  border: 1px solid var(--border);
}

#install table,
#install + fieldset table {
  width: 100%;
  border-collapse: collapse;
}

#install td,
#install + fieldset td {
  padding: 0.5em 1em;
  border-bottom: 0;
}

#install td:empty {
  width: 13.1em;
}

#install table form:nth-child(odd),
#install + fieldset tr:nth-child(odd) {
  background: var(--surface-muted);
}

#install fieldset > form {
  margin-top: 2em;
  text-align: center;
}

#install form {
  display: table;
  width: 100%;
}

#install td:last-child { text-align: left; }

#install .info { width: 19em; }

#install input[type="submit"] {
  min-width: 10.5em;
}

#install + fieldset table {
  font-size: 0.9em;
}

#install + fieldset td:first-child input[type="submit"] {
  background: none;
  padding: 0;
  min-height: 0;
  margin: 0;
  box-shadow: none;
  color: var(--accent);
  font-weight: bold;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#install + fieldset td:first-child input[type="submit"]:hover,
#install + fieldset td:first-child input[type="submit"]:focus {
  background: none;
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ==========================================================================
   7 = Admin
   ========================================================================== */

#admin fieldset,
#admin + fieldset {
  width: auto;
  max-width: 60em;
  border: 1px solid var(--border);
}

#admin table,
#admin + fieldset table {
  width: 100%;
  border-collapse: collapse;
  border-bottom: 1px solid var(--border);
}

#admin td,
#admin + fieldset td {
  padding: 0.5em 1em;
  border: 1px solid var(--border);
  border-bottom: 0;
  color: var(--foreground);
}

#admin td:empty {
  width: 13.1em;
}

#admin table form:nth-child(odd),
#admin + fieldset tr:nth-child(odd) {
  background: var(--surface-muted);
}

#admin + fieldset tr:hover {
  background: var(--surface-muted);
}

#admin fieldset > form {
  margin-top: 2em;
  text-align: center;
}

#admin form {
  display: table;
  width: 100%;
}

#admin td:last-child { text-align: left; }

#admin .info { width: 19em; }

#admin input[type="submit"] {
  min-width: 10.5em;
}

#admin + fieldset table {
  font-size: 0.9em;
}

#admin + fieldset td:first-child input[type="submit"] {
  background: none;
  padding: 0;
  min-height: 0;
  margin: 0;
  box-shadow: none;
  color: var(--accent);
  font-weight: bold;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#admin + fieldset td:first-child input[type="submit"]:hover,
#admin + fieldset td:first-child input[type="submit"]:focus {
  background: none;
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ==========================================================================
   8 = Download page
   ========================================================================== */

#self_destruct {
  font-weight: bold;
  color: var(--destructive);
  background-image: url('pixel_bomb.png');
  background-size: 40px 40px;
  background-repeat: no-repeat;
  padding-left: 40px;
  padding-top: 10px;
  padding-bottom: 10px;
}

/* ==========================================================================
   9 = 管理ログインカードの整形（QA 2026-08-18）
   admin.php は fieldset > table 構造（label 行 / input 行 / submit 行）。
   汎用 fieldset の固定 em 寸法（min-width 30em / min-height 15em）が
   狭い窓で input(size=40) をカード外へはみ出させ、下部に死に余白を作っていた。
   ここで枠を border-box + max-width にし、フォームを縦一列の素直な形へ。
   ========================================================================== */
form.login fieldset {
  display: block;            /* 冒頭の .login fieldset { display:flex } を打ち消す */
  box-sizing: border-box;
  width: 100%;
  max-width: 420px;
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
  padding: 24px;
}
form.login table,
form.login tbody,
form.login tr,
form.login td {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0;
}
form.login td.label {
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--foreground-muted);
}
form.login td.field { margin-bottom: 16px; }
form.login input[type="password"],
form.login input[type="text"] {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
}
form.login input[type="submit"] {
  width: 100%;
  margin: 0;
}

/* はみ出しの一般防御: どのフォーム部品もカードの内側に収まる */
fieldset { box-sizing: border-box; max-width: 100%; }
fieldset input, fieldset select, fieldset textarea { box-sizing: border-box; max-width: 100%; }
