/* ページ公開（solution-uploader）の画面。落ち着いた業務用の見た目で、読みやすさを優先する。 */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #55606e;
  --line: #d3d8df;
  --line-strong: #9aa4b1;
  --primary: #14508c;
  --primary-hover: #0e3d6d;
  --primary-soft: #e8f0f8;
  --danger: #b3261e;
  --danger-hover: #8c1d17;
  --danger-soft: #fdecea;
  --warn-soft: #fff6d6;
  --warn-line: #d9a400;
  --warn-text: #5c4500;
  --ok: #1b6b3a;
  --ok-soft: #e7f4ec;
  --focus: #e07b00;
  --radius: 8px;
}

*,
*::before,
*::after {
  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: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

h1,
h2,
p,
ul,
dl,
dd {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.boot {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.stack > * + * {
  margin-top: 20px;
}

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-danger-outline {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-small {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.btn-large {
  min-height: 52px;
  padding: 12px 40px;
  font-size: 1.1rem;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -80px;
  z-index: 10;
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}

.skip-link:focus {
  top: 8px;
}

/* ---------- ヘッダー ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner,
.nav-wrap,
.main {
  max-width: 960px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 12px;
  padding-bottom: 8px;
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 14px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--primary);
}

.nav-link[aria-current="page"] {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.main {
  padding-top: 28px;
  padding-bottom: 64px;
}

.main:focus {
  outline: none;
}

/* ---------- 共通の部品 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.card > * + * {
  margin-top: 16px;
}

.page-title {
  font-size: 1.5rem;
  line-height: 1.4;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lead {
  color: var(--muted);
}

.section-title,
.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  line-height: 1.4;
}

.step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
}

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

.working {
  color: var(--muted);
}

.field > * + * {
  margin-top: 6px;
}

.label {
  display: block;
  font-weight: 600;
}

.label-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

.input {
  display: block;
  width: 100%;
  max-width: 520px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.input:disabled {
  background: var(--bg);
}

.select {
  /* 「変更しない（いまの期限: YYYY/MM/DD まで）」が切れずに入る幅。狭い画面では親の幅まで。 */
  max-width: 100%;
  width: 26em;
}

.field-status:empty {
  display: none;
}

.field-status {
  font-size: 0.9rem;
}

.field-status[data-kind="error"] {
  color: var(--danger);
  font-weight: 600;
}

.field-status[data-kind="ok"] {
  color: var(--ok);
  font-weight: 600;
}

.field-status[data-kind="info"] {
  color: var(--muted);
}

.alert {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 6px;
  background: var(--surface);
}

.alert-error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.alert-warn {
  border-color: var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn-text);
}

.alert-info {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.alert-success {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.badge,
.count-badge {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-expired {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.badge-soon {
  border-color: var(--warn-line);
  background: #ffe27a;
  color: #3d2e00;
}

.badge-ok {
  border-color: var(--line);
  color: var(--text);
}

/* ---------- ログイン ---------- */
.login {
  max-width: 480px;
  margin: 0 auto;
  padding: 56px 16px;
}

.login-title {
  font-size: 1.6rem;
}

.gsi-box {
  min-height: 48px;
}

.gsi-box > * + * {
  margin-top: 12px;
}

/*
 * Google のログインボタン。Google のスクリプトは、ボタンの下書き（iframe が出るまでの仮の表示）用の
 * スタイルをインラインで差し込むが、CSP（インラインのスタイルは不可）で止まる。
 * そのままだとロゴが巨大に表示されるので、仮の表示の見た目をここで決めておく。
 */
.gsi-button svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.gsi-button [role="button"] {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.gsi-button [role="button"] > div:last-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gsi-button #button-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.gsi-button iframe {
  max-width: 100%;
}

/* ---------- 公開・差し替え ---------- */
.url-preview {
  margin-top: 8px;
  font-size: 0.95rem;
}

.url-preview:empty {
  display: none;
}

.url,
.url-fixed,
.page-url,
.file-path {
  font-family: Consolas, "SFMono-Regular", Menlo, "BIZ UDGothic", monospace;
  font-size: 0.92rem;
}

.url strong {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0 2px;
}

.url em {
  color: var(--muted);
  font-style: normal;
}

.dropzone {
  padding: 28px 16px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fafbfc;
  text-align: center;
}

.dropzone > * + * {
  margin-top: 10px;
}

.dropzone.is-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone-main {
  font-size: 1.1rem;
  font-weight: 700;
}

.dropzone-or {
  color: var(--muted);
  font-size: 0.9rem;
}

.pick-buttons,
.file-tools,
.done-actions,
.done-next,
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pick-buttons {
  justify-content: center;
}

.rules {
  color: var(--muted);
  font-size: 0.9rem;
}

.rules summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
}

.rules ul {
  margin-top: 8px;
  padding-left: 1.4em;
  list-style: disc;
}

.file-status:empty,
.file-area:empty,
.missing:empty,
.result-error:empty,
.list-notice:empty,
.login-notice:empty {
  display: none;
}

.file-area > * + * {
  margin-top: 12px;
}

.file-summary {
  font-weight: 600;
}

.over {
  color: var(--danger);
}

.file-list {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.file {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 2px 8px;
  align-items: baseline;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.file:last-child {
  border-bottom: 0;
}

.file-mark {
  font-weight: 700;
  text-align: center;
}

.file-ok .file-mark {
  color: var(--ok);
}

.file-ng {
  background: var(--danger-soft);
}

.file-ng .file-mark {
  color: var(--danger);
}

.file-size {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.file-reason {
  grid-column: 2 / -1;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

.missing {
  color: var(--muted);
  font-size: 0.95rem;
}

.missing li + li {
  padding-left: 1.2em;
  text-indent: -1.2em;
}

.missing li + li::before {
  content: "・";
}

.missing-head {
  font-weight: 600;
  color: var(--text);
}

.progress-bar {
  display: block;
  width: 100%;
  height: 22px;
  accent-color: var(--primary);
}

.progress-count {
  font-weight: 600;
}

.progress-title:focus,
.done-title:focus {
  outline: none;
}

.done-title {
  color: var(--ok);
  font-size: 1.4rem;
}

.url-box {
  max-width: none;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 1.15rem;
  font-weight: 600;
}

.copy-status {
  font-size: 0.9rem;
  color: var(--ok);
  font-weight: 600;
}

.done-next {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ---------- 一覧 ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
  padding: 16px 24px;
}

.toolbar > * + * {
  margin-top: 0;
}

.field-inline {
  flex: 1 1 220px;
}

.field-inline .input {
  max-width: none;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
}

.list-count {
  color: var(--muted);
  font-size: 0.9rem;
}

.page-list > * + * {
  margin-top: 12px;
}

.page-card > * + * {
  margin-top: 10px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}

.page-name {
  font-size: 1.1rem;
  line-height: 1.5;
}

.page-note {
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

.metas {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.meta {
  display: flex;
  gap: 6px;
}

.meta dt::after {
  content: ":";
}

.meta dd {
  color: var(--text);
}

.empty {
  color: var(--muted);
  text-align: center;
}

/* ---------- ダイアログ ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  overflow-y: auto;
}

.dialog::backdrop {
  background: rgba(20, 28, 40, 0.55);
}

.dialog-form {
  padding: 24px;
}

.dialog-form > * + *,
.dialog-body > * + * {
  margin-top: 16px;
}

.dialog-title {
  font-size: 1.2rem;
  line-height: 1.4;
}

.dialog-error {
  padding: 10px 14px;
  border: 1px solid var(--danger);
  border-left-width: 5px;
  border-radius: 6px;
  background: var(--danger-soft);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.dl-row {
  display: grid;
  grid-template-columns: 6em minmax(0, 1fr);
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.dl-row dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.dl-row dd {
  font-weight: 600;
}

/* ---------- 管理 ---------- */
.section-title .count-badge {
  margin-left: 4px;
}

.admin-list {
  border: 1px solid var(--line);
  border-radius: 6px;
}

.admin-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.admin-row:last-child {
  border-bottom: 0;
}

.admin-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.admin-email {
  font-weight: 600;
}

.admin-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.add-admin,
.settings-form {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.add-admin > * + *,
.settings-form > * + * {
  margin-top: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.settings-grid .input {
  max-width: 160px;
}

@media (max-width: 560px) {
  .card {
    padding: 16px;
  }

  .toolbar {
    padding: 16px;
  }

  .main {
    padding-top: 20px;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .btn-large {
    width: 100%;
  }

  .pick-buttons .btn {
    flex: 1 1 100%;
  }

  .dialog-form {
    padding: 16px;
  }

  .dialog-actions .btn {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .dropzone {
    transition: background-color 0.12s, border-color 0.12s;
  }
}
