/* Guardians of the Silver Age / 銀齡守護者
   Palette derived from colortone.png — teal / mint. */
:root {
  --primary: #4FC3B0;
  --primary-dark: #3BA696;
  --primary-darker: #2E8C7E;
  --primary-light: #7FD4C5;
  --primary-lighter: #D5F1EB;
  --primary-gradient: linear-gradient(135deg, #4FC3B0 0%, #3BA696 100%);
  --bg: #F5FAF9;
  --surface: #FFFFFF;
  --text: #1F3A37;
  --text-2: #4B6664;
  --text-muted: #8FA3A1;
  --border: #DDE8E6;
  --border-strong: #B9D1CC;
  --warn: #E08732;
  --danger: #D9534F;
  --star-filled: #F5B74A;
  --star-empty: #D8DEDD;
  --shadow-sm: 0 1px 3px rgba(46, 140, 126, 0.08);
  --shadow-md: 0 4px 14px rgba(46, 140, 126, 0.12);
  --shadow-lg: 0 10px 32px rgba(46, 140, 126, 0.18);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
               "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 20px;         /* elderly-first: body ≥ 20pt */
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

button, .btn {
  font-family: inherit;
  font-size: 22px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 18px 24px;
  min-height: 64px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-lg); }

.btn-ghost {
  background: transparent;
  color: var(--primary-dark);
  border: 2px solid var(--border-strong);
}
.btn-ghost:hover:not(:disabled) { background: var(--primary-lighter); }

.btn-link {
  background: none;
  color: var(--text-2);
  text-decoration: underline;
  min-height: auto;
  padding: 8px;
  font-weight: 500;
}

/* Layout ────────────────────────────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background:
    radial-gradient(circle at 110% -30%, rgba(255,255,255,0.22), transparent 55%),
    radial-gradient(circle at -5% 130%, rgba(245, 183, 74, 0.25), transparent 55%),
    linear-gradient(135deg, #5DD2BE 0%, #3BA696 55%, #2E8C7E 100%);
  color: white;
  padding: calc(18px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) 18px calc(20px + env(safe-area-inset-left));
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.app-header::after {
  /* thin gold hairline at the bottom edge — consistent with .scan-cta */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg,
    rgba(245, 183, 74, 0) 0%,
    rgba(245, 183, 74, 0.6) 50%,
    rgba(245, 183, 74, 0) 100%);
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}
.app-header .header-back {
  position: absolute;
  left: calc(14px + env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(255,255,255,0.2);
  transition: background 0.15s ease;
  z-index: 2;
}
.app-header .header-back:active,
.app-header .header-back:hover { background: rgba(255, 255, 255, 0.3); }
.app-header:has(.header-back) .brand { padding-left: 48px; }
.app-header .logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: white;           /* matches the PNG background so it blends seamlessly */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}
.app-header .logo img {
  width: 86%;               /* leave a little white ring so the mark doesn't touch the circle edge */
  height: 86%;
  object-fit: contain;      /* new logo is portrait — contain so nothing is clipped */
  display: block;
  image-rendering: -webkit-optimize-contrast;
}
.app-header .title-zh { font-size: 24px; font-weight: 700; margin: 0; }
.app-header .title-en { font-size: 14px; opacity: 0.9; margin: 0; }

main.container {
  flex: 1;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 22px;
  box-shadow: var(--shadow-md);
  margin-bottom: 18px;
}

.card h1, .card h2 {
  margin-top: 0;
  color: var(--text);
}
.card h2 { font-size: 22px; }

.muted { color: var(--text-muted); }
.help { font-size: 15px; color: var(--text-2); }

/* Worker card ───────────────────────────────────────────────────────── */
.worker-card {
  text-align: center;
  padding: 26px 20px;
  background: var(--primary-lighter);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.worker-card .avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
  margin: 0 auto 12px;
  box-shadow: var(--shadow-md);
}
.worker-card .name { font-size: 28px; font-weight: 700; margin: 0; }
.worker-card .role { color: var(--text-2); font-size: 18px; margin-top: 4px; }

.greeting {
  font-size: 20px;
  color: var(--text);
  margin: 18px 0 24px;
  line-height: 1.65;
}

/* Stars ─────────────────────────────────────────────────────────────── */
.rating-label { font-size: 22px; font-weight: 600; margin-bottom: 10px; }

.stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 22px;
  user-select: none;
}
.star {
  width: 68px; height: 68px;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px;
  color: var(--star-empty);
  cursor: pointer;
  transition: transform 0.12s ease, color 0.15s ease;
  line-height: 1;
}
.star.active { color: var(--star-filled); transform: scale(1.06); }
.star:active { transform: scale(0.92); }

.rating-words {
  text-align: center;
  font-size: 20px;
  color: var(--primary-dark);
  font-weight: 600;
  min-height: 28px;
  margin-bottom: 8px;
}

/* Tags ──────────────────────────────────────────────────────────────── */
.tags-label { font-size: 20px; font-weight: 700; margin-top: 12px; margin-bottom: 12px; }
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.tag {
  padding: 16px 22px;
  font-size: 21px;
  font-weight: 600;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-2);
  cursor: pointer;
  min-height: 60px;
  display: flex; align-items: center; gap: 8px;
  transition: all 0.12s ease;
}
.tag.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.tag .check { font-size: 18px; display: none; }
.tag.selected .check { display: inline; }

/* Comment ───────────────────────────────────────────────────────────── */
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 19px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 100px;
  resize: vertical;
  background: var(--bg);
}
textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); }

/* Buttons row ───────────────────────────────────────────────────────── */
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.actions .btn { width: 100%; }

.inline-actions {
  display: flex;
  gap: 12px;
}
.inline-actions .btn { flex: 1; }

/* Login / PIN ──────────────────────────────────────────────────────── */
.input-row { margin-bottom: 18px; }
.input-row label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 19px; }
input[type="text"], input[type="password"] {
  width: 100%;
  font-family: inherit;
  font-size: 21px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 60px;
}
input[type="text"]:focus, input[type="password"]:focus {
  outline: none; border-color: var(--primary);
}

/* iOS-style PIN display — small filled / empty dots */
.pin-display {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 22px 0 28px;
}
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--text-2);
  background: transparent;
  transition: background 0.12s ease, transform 0.1s ease;
  font-size: 0; /* hide digit — iOS shows dot only */
}
.pin-dot.filled {
  background: var(--text);
  border-color: var(--text);
  transform: scale(1.05);
}

/* iOS-style circular numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 22px;
  max-width: 320px;
  margin: 14px auto 0;
  justify-items: center;
}
.numpad button {
  /* perfect circle */
  width: 78px; height: 78px;
  min-height: 78px;
  border-radius: 50%;
  padding: 0;
  border: none;
  background: rgba(120, 138, 136, 0.14);
  color: var(--text);
  font-size: 32px;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
               "SF Pro Text", "Helvetica Neue", sans-serif;
  letter-spacing: 0.5px;
  box-shadow: none;
  transition: background 0.12s ease, transform 0.08s ease;
}
.numpad button:hover:not(:disabled) { background: rgba(120, 138, 136, 0.22); }
.numpad button:active:not(:disabled) {
  background: rgba(120, 138, 136, 0.32);
  transform: scale(0.96);
}
/* "清除" / "←" — plain text, no circle */
.numpad button.danger,
.numpad button[data-k="back"],
.numpad button[data-k="clear"] {
  background: transparent;
  color: var(--text-2);
  font-size: 18px;
  font-weight: 500;
}
.numpad button.danger:hover:not(:disabled),
.numpad button[data-k="back"]:hover:not(:disabled),
.numpad button[data-k="clear"]:hover:not(:disabled) {
  background: rgba(120, 138, 136, 0.10);
  color: var(--text);
}
.numpad button.ghost { visibility: hidden; }

@media (max-width: 380px) {
  .numpad { gap: 12px 16px; }
  .numpad button { width: 68px; height: 68px; min-height: 68px; font-size: 28px; }
}

/* Banners ─────────────────────────────────────────────────────────── */
.banner {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  margin-bottom: 14px;
}
.banner.info { background: var(--primary-lighter); color: var(--primary-darker); }
.banner.error { background: #FCE8E7; color: var(--danger); }
.banner.warn { background: #FCF2E3; color: var(--warn); }

.hello-chip {
  display: inline-flex; align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--primary-lighter);
  color: var(--primary-darker);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* Thank-you ────────────────────────────────────────────────────────── */
.thankyou-hero {
  text-align: center;
  padding: 36px 20px;
}
.thankyou-hero .ring {
  width: 120px; height: 120px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.35), transparent 55%),
    linear-gradient(135deg, #5DD2BE 0%, #3BA696 55%, #2E8C7E 100%);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  color: white; font-size: 60px;
  box-shadow:
    0 0 0 6px rgba(245, 183, 74, 0.2),
    var(--shadow-lg);
  position: relative;
}
.thankyou-hero .ring::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px solid rgba(245, 183, 74, 0.35);
  pointer-events: none;
}
.thankyou-hero h1 { font-size: 28px; margin: 8px 0; }
.thankyou-hero p { font-size: 18px; color: var(--text-2); }

/* Admin ──────────────────────────────────────────────────────────── */
.admin-shell { max-width: 1100px; margin: 0 auto; padding: 24px 20px 40px; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
}
.stat .label { color: var(--text-muted); font-size: 14px; }
.stat .value { font-size: 28px; font-weight: 700; color: var(--primary-darker); }

.filters {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  align-items: end;
}
.filters label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.filters select, .filters input {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  min-height: 42px;
  background: var(--surface);
}
.filters .btn { min-height: 42px; padding: 10px 16px; font-size: 15px; }

.table {
  width: 100%;
  background: var(--surface);
  border-collapse: collapse;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 15px;
}
.table th, .table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th { background: var(--primary-lighter); color: var(--primary-darker); font-weight: 700; font-size: 13px; }
.table tr:last-child td { border-bottom: none; }
.table .stars-cell { color: var(--star-filled); font-size: 17px; letter-spacing: 1px; }
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-anon { background: #FCE8E7; color: var(--danger); }
.badge-tag { background: var(--primary-lighter); color: var(--primary-darker); margin-right: 4px; }
.hint-box {
  background: #FCF2E3;
  color: var(--warn);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 4px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.hint-box button {
  font-size: 13px;
  min-height: auto;
  padding: 4px 10px;
  border-radius: 999px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background:
    radial-gradient(circle at 110% -30%, rgba(255,255,255,0.22), transparent 55%),
    radial-gradient(circle at -5% 130%, rgba(245, 183, 74, 0.22), transparent 55%),
    linear-gradient(135deg, #5DD2BE 0%, #3BA696 55%, #2E8C7E 100%);
  color: white;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.admin-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg,
    rgba(245, 183, 74, 0) 0%,
    rgba(245, 183, 74, 0.6) 50%,
    rgba(245, 183, 74, 0) 100%);
}
.admin-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.admin-header .logo {
  width: 36px; height: 36px; border-radius: 50%;
  background: white; color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.admin-header .btn-link { color: white; }

/* Onboarding / test ──────────────────────────────────────────────── */
.qr-hint {
  display: flex; gap: 14px;
  background: var(--primary-lighter);
  padding: 14px; border-radius: var(--radius);
  margin-bottom: 14px;
}
.qr-hint .icon {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

/* Test / dev helper list ─────────────────────────────────────────── */
.dev-links {
  background: #FFF8E1;
  border: 1px dashed #E0B33E;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #6B4E08;
  margin-bottom: 18px;
}
.dev-links strong { display: block; margin-bottom: 6px; }
.dev-links a { display: inline-block; margin-right: 10px; }

/* Responsive tweaks ─────────────────────────────────────────────── */
@media (max-width: 420px) {
  .star { width: 54px; height: 54px; font-size: 40px; }
  .tag { padding: 12px 16px; font-size: 17px; }
}

/* Sticky bottom action bar ─────────────────────────────────────────
   Used on form pages (rating, login) so the primary action stays
   visible without the user scrolling. Lives OUTSIDE the .card as a
   sibling, so it can reach container edges without negative margins.
   22px horizontal padding aligns buttons with card content. */
.actions.actions-sticky {
  position: sticky;
  bottom: 0;
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
  margin-top: -6px;  /* small overlap with card's margin-bottom for a tighter feel */
  background: linear-gradient(180deg, rgba(245, 250, 249, 0) 0%, var(--bg) 22%);
  z-index: 5;
  pointer-events: none;  /* clicks pass through the gradient padding area to content behind */
}
.actions.actions-sticky .btn,
.actions.actions-sticky a.btn,
.actions.actions-sticky button {
  pointer-events: auto;  /* buttons themselves stay clickable */
}

/* Height-tier responsive compaction ───────────────────────────────
   Triggers on short viewports (older phones, landscape phones).
   Keeps the elderly-first readability floors:
   - body text ≥ 20px, button text ≥ 20px
   - tap targets ≥ 56px (above WCAG 44px) */
@media (max-height: 700px) {
  .app-header {
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-bottom: 10px;
  }
  .app-header .logo { width: 40px; height: 40px; }
  .app-header .title-zh { font-size: 20px; }
  .app-header .title-en { font-size: 12px; }

  main.container { padding: 14px 16px 24px; }

  .card { padding: 16px 16px; }

  .worker-card { padding: 18px 14px; margin-bottom: 14px; }
  .worker-card .avatar { width: 56px; height: 56px; font-size: 22px; }
  .worker-card .name { font-size: 24px; }

  .greeting { font-size: 18px; margin: 12px 0 16px; }

  .stars { gap: 6px; margin: 8px 0 14px; }
  .star { width: 56px; height: 56px; font-size: 44px; }

  .tags { gap: 8px; margin-bottom: 14px; }
  .tag { padding: 12px 16px; font-size: 18px; min-height: 52px; }

  textarea { min-height: 70px; font-size: 18px; }

  .pin-display { margin: 8px 0 12px; gap: 10px; }
  .numpad { gap: 8px 16px; margin-top: 6px; }
  .numpad button { width: 58px; height: 58px; min-height: 58px; font-size: 24px; }

  .actions { gap: 8px; margin-top: 10px; }

  button, .btn { min-height: 56px; padding: 14px 20px; font-size: 20px; }

  /* Sticky bar tightens slightly on short viewports */
  .actions.actions-sticky {
    padding: 10px 22px calc(10px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 600px) {
  .app-header {
    padding-top: calc(6px + env(safe-area-inset-top));
    padding-bottom: 6px;
  }
  .app-header .logo { width: 32px; height: 32px; }
  .app-header .title-zh { font-size: 18px; }
  .app-header .title-en { display: none; }

  main.container { padding: 10px 14px 16px; }
  .card { padding: 12px 14px; }

  .stars { margin: 4px 0 10px; }
  .star { width: 48px; height: 48px; font-size: 38px; }

  .numpad button { width: 56px; height: 56px; min-height: 56px; font-size: 24px; }
}
