:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --bg-end: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #64748b;
  --primary: #334155;
  --primary-dark: #1f2937;
  --accent: #2563eb;
  --success: #16a34a;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-modal: 12px;
  --radius-pill: 999px;
}

body.dark {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-end: #111827;
  --surface: #172033;
  --surface-soft: #111827;
  --border: #2b3548;
  --text: #e5e7eb;
  --muted: #a7b0c0;
  --primary: #7dd3fc;
  --primary-dark: #f8fafc;
  --accent: #60a5fa;
  --success: #22c55e;
  --danger-bg: #3f1d25;
  --danger-text: #fecdd3;
  --warning-bg: #422f12;
  --warning-text: #fde68a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-end) 0%, var(--bg) 48%, var(--bg-end) 100%);
  transition: background 0.2s ease, color 0.2s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.page {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 42px;
  flex: 1;
}

.topbar,
.brand,
.top-actions,
.status,
.notice-title-row,
.section-head,
.service-top,
.editor-actions {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand,
.top-actions,
.status {
  align-items: center;
}

.brand {
  gap: 12px;
}

.logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--surface);
  font-weight: 800;
}

body.dark .logo {
  color: #0f172a;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status {
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-pill);
  background: var(--success);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 15%, transparent);
}

.admin-button,
.secondary-button,
.primary-button,
.danger-button,
.icon-button {
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.admin-button,
.secondary-button,
.icon-button {
  padding: 9px 13px;
  background: var(--surface);
  color: var(--primary-dark);
  border: 1px solid var(--border);
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.primary-button {
  padding: 11px 15px;
  background: var(--primary);
  color: var(--surface);
}

body.dark .primary-button {
  color: #0f172a;
}

.danger-button {
  padding: 11px 15px;
  background: var(--danger-bg);
  color: var(--danger-text);
}

.admin-button:hover,
.secondary-button:hover,
.primary-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.1);
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  margin-bottom: 26px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.intro {
  padding: 36px;
}

.label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  margin-bottom: 18px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

h1 {
  margin: 0;
  color: var(--primary-dark);
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.08;
}

.lead {
  max-width: 700px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.85;
}

.notice {
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
  border-left: 5px solid var(--primary);
}

.notice-title-row {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.notice h2,
.section-head h2,
.modal-header h2,
.form-section h3 {
  margin: 0;
  color: var(--primary-dark);
}

.notice h2 {
  font-size: 21px;
}

.notice-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: var(--radius-pill);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 12px;
  font-weight: 800;
}

.notice p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
  white-space: pre-line;
}

.notice-time {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.section-head {
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 28px 0 16px;
}

.section-head h2 {
  font-size: 22px;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.search-input {
  width: min(320px, 100%);
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.search-input:focus,
.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.service {
  display: flex;
  flex-direction: column;
  min-height: 164px;
  padding: 22px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.service:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.service-top {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}

.icon-image {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.external-mark {
  color: var(--muted);
  font-size: 18px;
}

.service strong {
  color: var(--primary-dark);
  display: block;
  font-size: 20px;
  margin-bottom: 8px;
}

.service span {
  color: var(--muted);
  line-height: 1.65;
  font-size: 15px;
}

.footer {
  width: min(1120px, calc(100% - 40px));
  margin: auto auto 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.54);
  z-index: 10;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  width: min(900px, 100%);
  max-height: min(88vh, 860px);
  overflow: auto;
  border-radius: var(--radius-modal);
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(8px);
}

.modal-header h2 {
  font-size: 20px;
}

.modal-body {
  padding: 24px;
}

.form-section {
  margin-bottom: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.form-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.form-section h3 {
  margin-bottom: 14px;
  font-size: 17px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.field textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.6;
}

.service-editor-list,
.login-box {
  display: grid;
  gap: 12px;
}

.service-editor-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.editor-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .hero,
  .grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .search-input {
    width: 100%;
  }

  .intro,
  .notice,
  .modal-body {
    padding: 24px;
  }
}
