:root {
  color-scheme: light;
  --ink: #18201e;
  --muted: #66706d;
  --paper: #f5f1e8;
  --panel: #fffdf8;
  --line: #d8d2c5;
  --green: #174d3c;
  --green-soft: #dce9e2;
  --coral: #d65a42;
  --gold: #b78b37;
  --danger: #a33b30;
  --shadow: 0 18px 48px rgba(36, 45, 41, 0.09);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  font-size: 16px;
  background:
    linear-gradient(rgba(23, 77, 60, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 77, 60, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button,
input,
select,
a {
  font: inherit;
  font-size: 16px;
}

button,
input,
select {
  min-height: 46px;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--green);
  text-underline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
.brand-name {
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  letter-spacing: 0.045em;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--ink);
  color: white;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--green);
  border-radius: 50%;
  color: var(--green);
  font-family: Georgia, serif;
  font-size: 24px;
  line-height: 1;
}

.brand-name {
  display: block;
  font-weight: 700;
}

.brand-caption {
  display: block;
  color: var(--muted);
  font-size: 15px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid var(--green);
  border-radius: 7px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover,
button:hover {
  box-shadow: 0 7px 18px rgba(23, 77, 60, 0.18);
  transform: translateY(-1px);
}

.button:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(214, 90, 66, 0.35);
  outline-offset: 2px;
}

.button.secondary,
button.secondary {
  background: transparent;
  color: var(--green);
}

.button.quiet,
button.quiet {
  min-height: 40px;
  padding: 7px 11px;
  border-color: transparent;
  background: transparent;
  color: var(--green);
  font-weight: 600;
}

button:disabled {
  cursor: progress;
  opacity: 0.58;
  transform: none;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--coral);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

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

.auth-layout {
  display: grid;
  min-height: calc(100vh - 48px);
  grid-template-columns: 1fr;
  align-items: center;
  gap: 32px;
}

.auth-intro {
  padding: 12px 4px 0;
}

.auth-intro h1 {
  max-width: 620px;
  margin-bottom: 18px;
  font-size: clamp(2.25rem, 9vw, 5.4rem);
  line-height: 0.98;
}

.auth-intro p:last-child {
  max-width: 520px;
  color: var(--muted);
}

.auth-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card {
  overflow: hidden;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  min-height: 52px;
  border: 0;
  border-radius: 0;
  background: #eee9df;
  color: var(--muted);
  box-shadow: none;
}

.auth-tab:hover {
  box-shadow: none;
  transform: none;
}

.auth-tab[aria-selected="true"] {
  background: var(--panel);
  color: var(--green);
}

.auth-panel {
  padding: 26px 22px 24px;
}

.auth-panel[hidden],
[hidden] {
  display: none !important;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 17px;
}

.field label,
.field-label {
  font-weight: 700;
}

.field small {
  color: var(--muted);
  font-size: 15px;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #bdb7aa;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 23px;
}

.form-actions button {
  flex: 1;
}

.message {
  min-height: 26px;
  margin: 16px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.message.success {
  color: var(--green);
}

.dashboard-head {
  display: grid;
  gap: 18px;
  padding: 34px 0 24px;
}

.dashboard-head h1 {
  margin-bottom: 4px;
  font-size: clamp(2rem, 7vw, 3.8rem);
  line-height: 1.06;
}

.club-control {
  min-width: min(100%, 330px);
}

.tablist {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 253, 248, 0.74);
}

.data-tab {
  flex: 1 0 auto;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.data-tab:hover {
  box-shadow: none;
}

.data-tab[aria-selected="true"] {
  background: var(--green);
  color: white;
}

.content-panel {
  min-height: 360px;
  margin-top: 18px;
  padding: 20px 16px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin-bottom: 3px;
  font-size: 1.55rem;
}

.status-note {
  padding: 16px;
  border-left: 4px solid var(--gold);
  background: #f5ecd9;
}

.status-note.error {
  border-color: var(--danger);
  background: #f6e4e1;
}

.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.loading::before {
  width: 18px;
  height: 18px;
  border: 3px solid var(--green-soft);
  border-top-color: var(--green);
  border-radius: 50%;
  content: "";
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7f0;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 15px;
}

.metric-value {
  display: block;
  margin-top: 3px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid #e6e0d5;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f0ece3;
  color: #3f4946;
  font-size: 15px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbf8f1;
}

.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.journal-filters {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7f0;
}

.journal-filters .field {
  margin: 0;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

.pager-status {
  min-width: 104px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.offline-layout,
.simple-layout {
  display: grid;
  min-height: calc(100vh - 120px);
  place-items: center;
  padding: 40px 0;
}

.state-card,
.simple-card {
  width: min(100%, 600px);
  padding: 30px 24px;
}

.state-symbol {
  display: grid;
  width: 74px;
  height: 74px;
  margin-bottom: 22px;
  place-items: center;
  border: 2px solid var(--coral);
  border-radius: 50%;
  color: var(--coral);
  font-family: Georgia, serif;
  font-size: 38px;
}

.state-card h1,
.simple-card h1 {
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 1.08;
}

.state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.session-person {
  max-width: 210px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 760px) {
  .page-shell {
    width: min(1180px, calc(100% - 64px));
    padding-top: 32px;
  }

  .auth-layout {
    grid-template-columns: minmax(0, 1.2fr) minmax(400px, 0.8fr);
    gap: 7vw;
  }

  .auth-panel {
    padding: 32px;
  }

  .dashboard-head {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .content-panel {
    padding: 28px;
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .journal-filters {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
  }

  .brand-caption,
  .session-person {
    display: none;
  }

  .top-actions {
    align-items: flex-end;
    flex-direction: column;
    gap: 3px;
  }

  .top-actions .button,
  .top-actions button {
    min-height: 38px;
    padding: 6px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
