/* ID 基盤（auth）の画面の CSS。portal の app.css を写したもの（モジュールが独立しているため複製している）。
   方向性：正確で静か、実務の道具。色は状態の意味にだけ使う。
   印：正方形の LED（状態）と、技術的な値（ホスト名、メールアドレス、日付）の IBM Plex Mono。 */

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}

:root {
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Hiragino Sans", "Noto Sans JP", monospace;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --raised: #eceef1;
  --sunken: #f1f3f5;
  --line: rgba(20, 24, 31, 0.10);
  --line-strong: rgba(20, 24, 31, 0.20);
  --text: #14181f;
  --text-2: #4a5260;
  --text-3: #646c7a;
  --accent: #1d5bbf;
  --accent-ink: #1a52ad;
  --accent-tint: rgba(29, 91, 191, 0.06);
  --focus: #2f6fdb;

  /* 状態の色（LED と、意味のある箇所だけに使う） */
  --ok: #1f9d57;
  --busy: #2f74e0;
  --wait: #d58a0a;
  --bad: #d83a3a;
  --off: #a2a8b1;
  --bad-ink: #b42828;
  --bad-line: rgba(196, 40, 40, 0.30);
  --bad-tint: rgba(216, 58, 58, 0.05);

  --btn-bg: #14181f;
  --btn-fg: #ffffff;
  --btn-hover: #2a303a;


  --shadow-sm: 0 1px 2px rgba(20, 24, 31, 0.05);
  --shadow-md: 0 8px 24px rgba(20, 24, 31, 0.07);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #171a1f;
    --raised: #20242a;
    --sunken: #0d0f12;
    --line: rgba(236, 239, 243, 0.08);
    --line-strong: rgba(236, 239, 243, 0.16);
    --text: #e8ebef;
    --text-2: #a9b0bb;
    --text-3: #868e9a;
    --accent: #6fa3f2;
    --accent-ink: #84b1f5;
    --accent-tint: rgba(111, 163, 242, 0.08);
    --focus: #84b1f5;

    --ok: #46c27f;
    --busy: #5b97f0;
    --wait: #e6a23c;
    --bad: #ec6363;
    --off: #6b727c;
    --bad-ink: #f08080;
    --bad-line: rgba(236, 99, 99, 0.35);
    --bad-tint: rgba(236, 99, 99, 0.06);

    --btn-bg: #e8ebef;
    --btn-fg: #111317;
    --btn-hover: #ffffff;


    --shadow-sm: none;
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

/* ---------- 土台 ---------- */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  font-feature-settings: "palt" 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, fieldset, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
img, svg { display: block; }
strong, b { font-weight: 600; }
/* 日本語は文節で折り返す（対応していないブラウザでは通常の折り返し） */
body { word-break: auto-phrase; }
h1, h2, h3 { text-wrap: balance; }

a { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
.strong { font-weight: 600; color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.skip {
  position: absolute; left: 16px; top: -48px; z-index: 10;
  padding: 8px 12px; border-radius: 8px;
  background: var(--btn-bg); color: var(--btn-fg); text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- 状態の LED（このプロダクトの印） ---------- */

.led {
  display: inline-block; flex: none;
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--off);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.led-ok { background: var(--ok); }
.led-busy { background: var(--busy); }
.led-wait { background: var(--wait); }
.led-bad { background: var(--bad); }
.led-off { background: var(--off); }

/* 処理が実際に動いているときだけ、活動 LED のように点滅させる */
.is-busy .led, .led.is-blink { animation: blink 1.6s steps(2, jump-none) infinite; }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) {
  .is-busy .led, .led.is-blink { animation: none; }
}

.state {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; line-height: 20px; color: var(--text);
  white-space: nowrap;
}
.state-off { color: var(--text-2); }

/* ---------- ボタン ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease), transform 120ms var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { background: var(--btn-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--raised); text-decoration: none; }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.btn-quiet-danger:hover { color: var(--bad-ink); }
.btn-danger { background: var(--bad-ink); color: #fff; }
.btn-danger:hover { background: #9c2020; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }

@media (prefers-color-scheme: dark) {
  .btn-danger { background: #c43c3c; }
  .btn-danger:hover { background: #d44a4a; }
}

.linklike {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; color: inherit;
}
.linklike:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
form.inline { display: inline; }

/* ---------- 利用者ポータルの枠 ---------- */

.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-in {
  max-width: 1120px; margin: 0 auto; padding: 0 32px;
  height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
/* 印：鍵穴を正面から見た形（portal のポートの印と同じ線と角） */
.brand-mark {
  position: relative; width: 16px; height: 16px; flex: none;
  border: 1.5px solid currentColor; border-radius: 3px;
}
.brand-mark::before {
  content: ""; position: absolute; left: 50%; top: 3px; width: 4px; height: 4px; margin-left: -2px;
  background: currentColor; border-radius: 50%;
}
.brand-mark::after {
  content: ""; position: absolute; left: 50%; top: 6px; width: 2px; height: 4px; margin-left: -1px;
  background: currentColor; border-radius: 1px;
}
.topnav { display: flex; align-items: center; gap: 24px; font-size: 14px; color: var(--text-2); white-space: nowrap; }
.topnav a:not(.btn) { color: var(--text-2); text-decoration: none; padding: 4px 0; border-top: 2px solid transparent; border-bottom: 2px solid transparent; }
.topnav a:not(.btn):hover { color: var(--text); }
.topnav a:not(.btn)[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }

.main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 40px 32px 64px; }
.main-auth { padding-top: 64px; }

.footer { border-top: 1px solid var(--line); color: var(--text-3); font-size: 13px; }
.footer-in { max-width: 1120px; margin: 0 auto; padding: 20px 32px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* ---------- 共通の部品 ---------- */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; min-height: 40px; }
.page-title { font-size: 26px; line-height: 1.3; font-weight: 500; }
.page-count { font-size: 15px; font-weight: 400; color: var(--text-3); margin-left: 8px; vertical-align: 3px; }
.page-lead { color: var(--text-2); font-size: 14px; margin: -8px 0 24px; max-width: 44rem; }

.crumbs { margin-bottom: 12px; font-size: 14px; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); text-decoration: none; margin-left: -4px; padding: 2px 4px; border-radius: 6px; }
.crumbs a:hover { color: var(--text); background: var(--raised); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; box-shadow: var(--shadow-sm);
}
.panel-title { font-size: 16px; font-weight: 500; line-height: 1.5; margin-bottom: 16px; }
.panel p + p { margin-top: 8px; }
.stack > * + * { margin-top: 24px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; margin-top: 24px; align-items: start; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 32px; box-shadow: var(--shadow-sm);
}
.card-narrow { max-width: 420px; margin: 0 auto; }
.card-title { font-size: 22px; font-weight: 500; line-height: 1.4; margin-bottom: 8px; }
.card-lead { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }
.card-title + .form, .card-title + .notice { margin-top: 24px; }
.card-foot { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 14px; color: var(--text-2); }

.msg-code { font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.msg-title { font-size: 22px; font-weight: 500; line-height: 1.4; margin-bottom: 12px; }
.msg-body { color: var(--text-2); font-size: 14px; }
.msg-body + .msg-body { margin-top: 8px; }
.msg-addr { margin-top: 16px; padding: 10px 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; font-size: 14px; overflow-wrap: anywhere; }
.msg .actions { margin-top: 24px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.actions-end { justify-content: flex-end; }

.flash, .notice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  font-size: 14px; line-height: 1.6;
}
.flash { margin-bottom: 24px; }
.flash .led, .notice .led { margin-top: 7px; }
.notice { margin-bottom: 20px; }
.notice-bad { border-color: var(--bad-line); background: var(--bad-tint); box-shadow: none; }

.empty {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 48px 24px; text-align: center;
}
.empty-title { font-size: 16px; font-weight: 500; }
.empty-text { color: var(--text-2); font-size: 14px; margin: 8px auto 0; max-width: 32rem; }
.empty .btn { margin-top: 20px; }

.errlog {
  margin-top: 12px; padding: 12px 16px; max-height: 240px; overflow: auto;
  background: var(--sunken); border: 1px solid var(--line); border-radius: 8px;
  font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text);
}

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

.form > * + * { margin-top: 20px; }
.form-narrow { max-width: 400px; }
.form-wide { max-width: 760px; }
.form-wide > .panel + .panel { margin-top: 16px; }
.form-wide > .actions { margin-top: 24px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field legend { font-size: 14px; font-weight: 500; line-height: 1.5; }
.field legend { margin-bottom: 12px; }
.legend-sub { font-weight: 400; color: var(--text-3); font-size: 13px; margin-left: 8px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.label-row a { font-size: 13px; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; height: 40px; padding: 0 12px;
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  transition: border-color 140ms var(--ease);
}
textarea { height: auto; min-height: 88px; padding: 10px 12px; line-height: 1.6; resize: vertical; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); border-radius: 8px; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
input.mono, textarea.mono { font-family: var(--mono); }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; }

.hint { font-size: 13px; color: var(--text-3); line-height: 1.6; }
/* 短い補足は、同じ内容のエラーが出ているあいだ隠す */
.field:has([aria-invalid="true"]) .hint-short { display: none; }
.field-error { font-size: 13px; color: var(--bad-ink); line-height: 1.6; }

.props > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.props > div:first-child { border-top: 0; padding-top: 0; }
.props dt { font-size: 13px; color: var(--text-3); line-height: 1.7; }
.props dd { font-size: 14px; min-width: 0; }
.props dd .errlog { margin-top: 0; }


/* ---------- ログイン先（利用側のサービス） ---------- */

.dest {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 2px 12px;
  margin: 4px 0 24px; padding: 12px 14px;
  background: var(--sunken); border: 1px solid var(--line); border-radius: 10px;
}
.dest-label { grid-row: 1 / span 2; font-size: 12px; color: var(--text-3); line-height: 22px; }
.dest-main { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; font-weight: 500; line-height: 22px; }
.dest-main .led { margin-top: 1px; }
.dest-bad { border-color: var(--bad-line); background: var(--bad-tint); }
.dest-name { overflow-wrap: anywhere; }
.dest-host { grid-column: 2; font-size: 12.5px; color: var(--text-3); line-height: 1.6; overflow-wrap: anywhere; }
.dest-label + .dest-host { grid-row: 1 / span 2; font-size: 14px; color: var(--text); line-height: 22px; }

/* ---------- パスキー ---------- */

.pk-block { margin-bottom: 4px; }
.pk-status { margin-top: 10px; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.pk-status[data-tone="bad"] { color: var(--bad-ink); }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; font-size: 13px; color: var(--text-3); }
.divider::before, .divider::after { content: ""; flex: 1; height: 0; border-top: 1px solid var(--line); }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; min-height: 32px; }
.panel-head .panel-title { margin-bottom: 0; }
.panel-count { margin-left: 8px; font-size: 13px; font-weight: 400; color: var(--text-3); }
.panel-lead { font-size: 14px; color: var(--text-2); max-width: 44rem; margin-bottom: 16px; }
.panel > .pk-status { margin: -8px 0 16px; }

.pklist { border: 1px solid var(--line); border-radius: 10px; }
.pk {
  display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 16px;
  min-height: 64px; padding: 12px 8px 12px 16px;
}
.pk + .pk { border-top: 1px solid var(--line); }
.pk > .led { align-self: start; margin-top: 8px; }
.pk-name { font-size: 15px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.pk-meta { display: flex; flex-wrap: wrap; gap: 2px 16px; margin-top: 2px; font-size: 13px; color: var(--text-3); line-height: 1.6; }
.pk-meta .mono { font-size: 12.5px; color: var(--text-2); }
.pk-actions { display: flex; gap: 4px; }
.pk-empty { padding: 28px 16px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 10px; }
.pk-empty-title { font-size: 15px; font-weight: 500; }
.pk-empty-text { margin-top: 4px; font-size: 13px; color: var(--text-2); }
.pk-note { margin-top: 12px; }

/* 行の右から開く小さな操作の枠 */
.pop { position: relative; }
.pop summary { list-style: none; }
.pop summary::-webkit-details-marker { display: none; }
.pop[open] summary { background: var(--raised); color: var(--text); }
.pop-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 5;
  width: 320px; max-width: calc(100vw - 32px); padding: 16px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-md);
}
.pop-panel .form > * + * { margin-top: 12px; }
.pop-panel .actions { margin-top: 12px; justify-content: flex-end; }
.pop-text { font-size: 14px; color: var(--text-2); }

.inline-form { max-width: 440px; }
.inline-form .field-error { margin-top: 6px; }
.props dt label { font-size: 13px; color: var(--text-3); line-height: 40px; font-weight: 400; }
.inline-row { display: flex; gap: 8px; }
.inline-row input { flex: 1; min-width: 0; }

.msg-detail { margin-top: 16px; font-size: 13px; color: var(--text-3); }
.msg-detail summary { cursor: pointer; width: fit-content; }
.msg-detail summary:hover { color: var(--text); }
.msg .dest { margin: 0 0 16px; }

/* ---------- 画面幅ごとの調整 ---------- */

@media (max-width: 640px) {
  .topbar-in { padding: 0 16px; }
  .topnav { gap: 16px; font-size: 13px; }
  .main { padding: 24px 16px 48px; }
  .main-auth { padding-top: 24px; }
  .footer-in { padding: 16px; }
  .card { padding: 24px 20px; }
  .panel { padding: 20px; }
  .page-title { font-size: 22px; }
  .props > div { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
  .pk { grid-template-columns: 8px minmax(0, 1fr); gap: 4px 12px; padding: 14px 12px 10px 14px; }
  .pk-actions { grid-column: 2; margin-left: -12px; }
  .pop-panel { right: auto; left: 0; }
  .pk-actions .pop:last-child .pop-panel { left: auto; right: auto; }
  .panel-head { align-items: flex-start; }
  .brand-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
