/* 1. 共通設定：色や角丸の変更はここで行います。 */
:root {
  color-scheme: light;
  --page: #f5f6f8;
  --surface: #ffffff;
  --text: #242e3b;
  --muted: #647080;
  --line: #dde2e8;
  --primary: #216a60;
  --primary-hover: #18554c;
  --danger: #ae302c;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: 28px; line-height: 1.4; letter-spacing: .02em; }
h2 { font-size: 16px; line-height: 1.5; }
a { color: var(--primary); }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #73aaeb; outline-offset: 3px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.field-help, .page-description { color: var(--muted); }
.field-help { margin-top: 8px; font-size: 12px; line-height: 1.7; }
.page-description { margin-top: 8px; }
.site-name { margin-bottom: 8px; color: var(--primary); font-size: 11px; font-weight: 750; letter-spacing: .14em; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }

/* 2. 入力欄とボタン：管理画面・ログイン画面で共用します。 */
input:not([type="hidden"]), select {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #bfc8d3;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
input:not([type="hidden"]) { width: 100%; min-width: 0; }
input::placeholder { color: #7b8693; }
input:hover, select:hover { border-color: #8e9aaa; }
input:focus, select:focus { border-color: var(--primary); }
.field { min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend { display: block; margin-bottom: 8px; padding: 0; font-size: 13px; font-weight: 650; }
.optional { margin-left: 6px; color: var(--muted); font-size: 11px; font-weight: 400; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button:hover { background: #edf1f5; border-color: #b8c2ce; }
.button--primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button--primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.button--danger { color: var(--danger); }
.button--danger:hover { border-color: #e0aaa7; background: #fff1ef; }
.duration-field, .time_field { display: inline-flex; align-items: center; gap: 6px; }
.duration-field select { min-width: 88px; }
.date_fields, .edit_form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.date_fields input[type="date"], .edit_form input[type="date"] { width: 148px; }
.time_field { color: var(--muted); font-size: 12px; }
.time_field select { width: 60px; font-size: 14px; }

/* 3. 管理画面：見出し、閲覧用の認証情報、追加フォーム。 */
.admin-shell { width: min(1320px, 100%); margin: 0 auto; padding: 40px 32px 64px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.timezone-note { padding-bottom: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.credentials { display: flex; align-items: center; flex-wrap: wrap; gap: 16px 32px; margin-bottom: 20px; padding: 16px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: #eef1f4; }
.credentials h2 { color: var(--muted); font-size: 13px; font-weight: 500; }
.credentials-list { display: flex; flex-wrap: wrap; gap: 12px 32px; }
.credentials-list > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; }
.credentials dt { color: var(--muted); font-size: 12px; }
.credentials code { font-family: ui-monospace, Consolas, monospace; font-size: 14px; overflow-wrap: anywhere; }
.notice { margin-bottom: 20px; padding: 12px 16px; border: 1px solid; border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
.notice--success { border-color: #c7dfd5; background: #edf7f1; color: #236146; }
.notice--error { border-color: #eac0bc; background: #fff1ef; color: var(--danger); }
.panel { margin-bottom: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.section-heading { padding: 20px 24px; }
.add-panel .section-heading { padding-bottom: 0; }
.add-form { padding: 20px 24px 24px; }
.url-fields { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 24px; }
.schedule-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 24px; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-footer .field-help { margin-top: 0; }
.form-footer .button { min-width: 100px; }

/* 4. 登録一覧と状態表示。 */
.list-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.checked-at { color: var(--muted); font-size: 11px; line-height: 1.8; text-align: right; }
.checked-at time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.url-table { width: 100%; border-collapse: collapse; text-align: left; }
.url-table th { padding: 12px 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #f8f9fb; color: var(--muted); font-size: 12px; font-weight: 550; white-space: nowrap; }
.url-table td { padding: 24px 20px; vertical-align: top; border-bottom: 1px solid var(--line); }
.url-table tbody tr:last-child td { border-bottom: 0; }
.url-cell { width: 31%; }
.duration-cell { width: 8%; white-space: nowrap; font-variant-numeric: tabular-nums; }
.schedule-cell { width: 45%; }
.actions-cell { width: 16%; }
.url_domain { margin-bottom: 4px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.url_path { font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.access_status { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 3px 9px; border-radius: 5px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.access_status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status_restricted { color: #875306; background: #fff3d7; }
.status_public { color: #1f6b47; background: #e8f5ec; }
.status_forbidden { color: #ad302a; background: #ffedeb; }
.schedule_item + .schedule_item { margin-top: 18px; padding-top: 18px; border-top: 1px solid #edf0f3; }
.schedule-summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.schedule-label { font-size: 12px; font-weight: 650; }
.schedule-value { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.edit_form .button { padding: 8px 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions form { margin: 0; }
.row-actions .button { padding: 8px 12px; }
.empty-state { padding: 40px 24px !important; color: var(--muted); text-align: center; }

/* 5. ログイン画面。 */
.login-page { display: grid; min-height: 100vh; min-height: 100svh; place-items: center; padding: 32px 20px; }
.login-card { width: min(440px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.login-card h1 { font-size: 24px; }
.login-card .page-description { font-size: 13px; }
.login-form { display: grid; gap: 20px; margin-top: 28px; }
.login-form input { font-size: 16px; }
.login-button { width: 100%; margin-top: 4px; }
.login-note:empty { display: none; }
.login-note { margin-top: 20px; color: var(--muted); font-size: 12px; }

/* 6. 小さい画面では一覧を縦に並べ、横スクロールを不要にします。 */
@media (max-width: 1000px) {
  .admin-shell { padding: 28px 20px 40px; }
  .url-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .url-table, .url-table tbody { display: block; }
  .url-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; padding: 24px; border-top: 1px solid var(--line); }
  .url-table td { display: block; width: auto; padding: 0; border: 0; }
  .url-table .duration-cell::before { content: "有効時間"; display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
  .url-table .duration-cell { text-align: right; }
  .url-table .schedule-cell, .url-table .actions-cell, .url-table .empty-state { grid-column: 1 / -1; }
  .row-actions { justify-content: flex-end; }
}
@media (max-width: 700px) {
  .page-header { align-items: flex-start; flex-direction: column; gap: 10px; }
  h1 { font-size: 24px; }
  .credentials { align-items: flex-start; flex-direction: column; gap: 12px; }
  .schedule-fields { grid-template-columns: minmax(0, 1fr); }
  .url-fields { grid-template-columns: minmax(0, 1fr) 140px; gap: 16px; }
  .list-heading { flex-direction: column; gap: 12px; }
  .checked-at { text-align: left; }
}
@media (max-width: 480px) {
  .admin-shell { padding: 24px 16px 32px; }
  .credentials, .section-heading, .url-table tbody tr { padding: 20px; }
  .add-form { padding: 20px; }
  .url-fields { grid-template-columns: minmax(0, 1fr); }
  .date_fields input[type="date"], .edit_form input[type="date"] { width: 100%; flex-basis: 100%; }
  .form-footer { align-items: flex-start; }
  .form-footer .button { min-width: 80px; }
  .login-card { padding: 28px 24px; }
  input:not([type="hidden"]), select { font-size: 16px; }
}
