/* ========================================================================
   Kyoto Clock — Lacquer × Washi × Metal Inlay
   ------------------------------------------------------------------------
   Design language: restrained Kyoto aesthetics pushed to the limit on
   lines, layered shadows, metallic gradients and light bands. Light mode
   is washi paper; dark mode is urushi lacquer. No images are required —
   every texture is drawn in CSS.
   ======================================================================== */

/* -------- 1. Design tokens ---------------------------------------------- */

:root {
  color-scheme: light;

  --bg: #faf7f2;
  --bg-2: #f2ece0;
  --bg-veil: rgba(255, 252, 246, 0.62);

  --surface: rgba(255, 252, 246, 0.86);
  --surface-hi: rgba(255, 255, 255, 0.94);
  --surface-solid: #fffdf7;

  --ink: #1a1d24;
  --ink-soft: #5a6270;
  --ink-faint: #8c94a0;

  --line: rgba(26, 29, 36, 0.08);
  --line-strong: rgba(26, 29, 36, 0.18);
  --line-gold: rgba(176, 138, 63, 0.45);

  --cinnabar: #b0413e;
  --cinnabar-hi: #c85b52;
  --cinnabar-lo: #8a2f2c;

  --gold: #b08a3f;
  --gold-hi: #e2c37a;
  --gold-lo: #6e5527;

  --sumi: #0f1115;
  --primary: var(--cinnabar);
  --primary-dark: var(--cinnabar-lo);
  --soft: var(--ink-soft);
  --panel: var(--surface);
  --panel-strong: var(--surface-hi);
  --shadow: 0 24px 48px -18px rgba(26, 29, 36, 0.22);

  --radius-xl: 32px;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-lift-1:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 1px 2px rgba(26, 29, 36, 0.04),
    0 8px 24px -12px rgba(26, 29, 36, 0.12);
  --shadow-lift-2:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 2px 4px rgba(26, 29, 36, 0.06),
    0 24px 48px -18px rgba(26, 29, 36, 0.22);
  --shadow-lift-3:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 2px 6px rgba(26, 29, 36, 0.08),
    0 40px 80px -28px rgba(26, 29, 36, 0.32);
  --shadow-inset-soft: inset 0 1px 2px rgba(26, 29, 36, 0.06);

  --metal-gold: linear-gradient(
    135deg,
    #6e5527 0%,
    #b08a3f 22%,
    #e2c37a 50%,
    #b08a3f 78%,
    #6e5527 100%
  );
  --metal-cinnabar: linear-gradient(
    180deg,
    #c85b52 0%,
    #b0413e 55%,
    #8a2f2c 100%
  );
  --metal-ink: linear-gradient(180deg, #2a2e39 0%, #14171d 100%);

  --light-band: linear-gradient(
    105deg,
    transparent 20%,
    rgba(255, 255, 255, 0.55) 48%,
    transparent 78%
  );
  --glow-cinnabar: 0 0 0 1px rgba(176, 65, 62, 0.24),
    0 18px 48px -12px rgba(176, 65, 62, 0.45);
  --glow-gold: 0 0 0 1px rgba(176, 138, 63, 0.28),
    0 14px 40px -14px rgba(176, 138, 63, 0.4);

  --grain:
    radial-gradient(1px 1px at 16% 28%, rgba(26, 29, 36, 0.05) 50%, transparent 60%),
    radial-gradient(1px 1px at 62% 71%, rgba(26, 29, 36, 0.04) 50%, transparent 60%),
    radial-gradient(1px 1px at 84% 22%, rgba(26, 29, 36, 0.035) 50%, transparent 60%),
    radial-gradient(1px 1px at 30% 84%, rgba(26, 29, 36, 0.03) 50%, transparent 60%);

  --dur-fast: 120ms;
  --dur-base: 220ms;
  --dur-slow: 480ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --font-serif: "Noto Serif JP", "Noto Serif TC", "Songti TC", Georgia, serif;
  --font-sans: "Inter", "Noto Sans TC", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Roboto Mono", ui-monospace, monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1014;
  --bg-2: #15181f;
  --bg-veil: rgba(14, 16, 20, 0.72);

  --surface: rgba(28, 32, 40, 0.78);
  --surface-hi: rgba(38, 42, 52, 0.92);
  --surface-solid: #1a1d24;

  --ink: #eae4d7;
  --ink-soft: #9aa0aa;
  --ink-faint: #5e6470;

  --line: rgba(234, 228, 215, 0.1);
  --line-strong: rgba(234, 228, 215, 0.22);
  --line-gold: rgba(212, 175, 106, 0.45);

  --cinnabar: #d65752;
  --cinnabar-hi: #ed7b74;
  --cinnabar-lo: #a83a38;

  --gold: #d4af6a;
  --gold-hi: #f3dfa0;
  --gold-lo: #8a6d38;

  --shadow-lift-1:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --shadow-lift-2:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 2px 6px rgba(0, 0, 0, 0.4),
    0 24px 48px -18px rgba(0, 0, 0, 0.6);
  --shadow-lift-3:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 2px 8px rgba(0, 0, 0, 0.5),
    0 40px 80px -28px rgba(0, 0, 0, 0.75);
  --shadow-inset-soft: inset 0 1px 2px rgba(0, 0, 0, 0.25);

  --metal-gold: linear-gradient(
    135deg,
    #8a6d38 0%,
    #d4af6a 22%,
    #f3dfa0 50%,
    #d4af6a 78%,
    #8a6d38 100%
  );
  --metal-cinnabar: linear-gradient(
    180deg,
    #ed7b74 0%,
    #d65752 55%,
    #a83a38 100%
  );
  --metal-ink: linear-gradient(180deg, #20232a 0%, #0c0e13 100%);

  --light-band: linear-gradient(
    105deg,
    transparent 20%,
    rgba(255, 255, 255, 0.18) 48%,
    transparent 78%
  );

  --grain:
    radial-gradient(1px 1px at 16% 28%, rgba(234, 228, 215, 0.06) 50%, transparent 60%),
    radial-gradient(1px 1px at 62% 71%, rgba(234, 228, 215, 0.05) 50%, transparent 60%),
    radial-gradient(1px 1px at 84% 22%, rgba(234, 228, 215, 0.04) 50%, transparent 60%),
    radial-gradient(1px 1px at 30% 84%, rgba(234, 228, 215, 0.035) 50%, transparent 60%);
}

/* -------- 2. Base & reset ---------------------------------------------- */

* {
  box-sizing: border-box;
}

*:focus {
  outline: none;
}

*:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(176, 65, 62, 0.22),
    0 0 0 1px var(--cinnabar);
  border-radius: inherit;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  background:
    radial-gradient(
      ellipse 60% 40% at 8% -6%,
      rgba(176, 65, 62, 0.1),
      transparent 60%
    ),
    radial-gradient(
      ellipse 40% 30% at 100% 8%,
      rgba(176, 138, 63, 0.09),
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 40% at 92% 104%,
      rgba(32, 74, 99, 0.06),
      transparent 60%
    ),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  transition: background-color var(--dur-base) var(--ease);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(
      ellipse 60% 40% at 8% -6%,
      rgba(214, 87, 82, 0.12),
      transparent 60%
    ),
    radial-gradient(
      ellipse 40% 30% at 100% 8%,
      rgba(212, 175, 106, 0.08),
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 40% at 92% 104%,
      rgba(90, 130, 160, 0.05),
      transparent 60%
    ),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
}

body.is-locked {
  overflow: hidden;
}

/* Washi / urushi grain veil — drawn entirely in CSS */
.page-grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: var(--grain);
  background-size: 160px 160px, 220px 220px, 180px 180px, 260px 260px;
  mix-blend-mode: overlay;
  opacity: 0.9;
}

img {
  display: block;
  max-width: 100%;
}

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

/* -------- 3. Typography ------------------------------------------------ */

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  font-feature-settings: "palt" 1;
}

h1 {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.05;
}

h2 {
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.15;
}

h3 {
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.2;
}

p {
  margin: 0;
}

strong {
  font-weight: 700;
}

small {
  font-size: 12px;
}

.eyebrow {
  margin: 0 0 10px;
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  background: var(--metal-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% 100%;
  background-position: 0% 50%;
  transition: background-position var(--dur-slow) var(--ease);
}

.eyebrow:hover {
  background-position: 100% 50%;
}

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

.hidden {
  display: none !important;
}

/* -------- 4. Layout containers ---------------------------------------- */

.landing-body,
.app-body,
.screen-body {
  min-height: 100vh;
  position: relative;
  z-index: 0;
}

.landing-shell,
.app-shell,
.screen-shell {
  position: relative;
  z-index: 2;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.app-shell {
  width: min(1040px, calc(100% - 32px));
  display: grid;
  gap: 22px;
  padding-top: 18px;
}

/* -------- 5. Topbar --------------------------------------------------- */

.topbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  width: min(1040px, calc(100% - 32px));
  margin: 10px auto 0;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift-2);
  isolation: isolate;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 0;
  height: 1px;
  background: var(--metal-gold);
  opacity: 0.55;
  pointer-events: none;
  border-radius: 1px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 0 0 auto;
}

/* Integrated top-of-page ad — lives inside the topbar so there's no extra block */
.topbar-ad {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 14px;
  margin: 0 4px;
  height: 56px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(
      135deg,
      rgba(176, 138, 63, 0.08),
      rgba(176, 65, 62, 0.05)
    ),
    var(--surface-hi);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift-1);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  isolation: isolate;
  transition:
    transform var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease);
}

.topbar-ad::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--light-band);
  transform: translateX(-120%);
  transition: transform 650ms var(--ease);
  pointer-events: none;
  mix-blend-mode: screen;
}

.topbar-ad:hover {
  transform: translateY(-1px);
  border-color: var(--line-gold);
  box-shadow: var(--shadow-lift-2), var(--glow-gold);
}

.topbar-ad:hover::after {
  transform: translateX(120%);
}

.topbar-ad-image {
  flex: 0 0 auto;
  height: 44px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--surface-hi);
}

.topbar-ad-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.topbar-ad-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-ad-caption {
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* When no image URL, image renders broken — hide it */
.topbar-ad-image:not([src]),
.topbar-ad-image[src=""] {
  display: none;
}

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

.topbar-title {
  font-family: var(--font-serif);
  font-size: clamp(20px, 2.2vw, 26px);
  letter-spacing: 0.02em;
  line-height: 1.05;
  margin: 4px 0 0;
}

.topbar-seal {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 10px;
  background: var(--metal-cinnabar);
  color: #fff4e8;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -8px 18px rgba(0, 0, 0, 0.25),
    0 6px 14px -6px rgba(176, 65, 62, 0.55);
  position: relative;
}

.topbar-seal::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface-hi);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -------- 6. Buttons --------------------------------------------------- */

.primary-btn,
.secondary-btn,
.ghost-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 0;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease),
    background var(--dur-base) var(--ease),
    color var(--dur-base) var(--ease);
  overflow: hidden;
  isolation: isolate;
}

.primary-btn > svg,
.secondary-btn > svg,
.ghost-btn > svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

/* Cinnabar lacquer — primary */
.primary-btn {
  color: #fff5e8;
  background: var(--metal-cinnabar);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -10px 18px rgba(0, 0, 0, 0.2),
    0 10px 24px -10px rgba(176, 65, 62, 0.6),
    0 1px 0 rgba(176, 65, 62, 0.8);
}

.primary-btn::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.primary-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--light-band);
  transform: translateX(-120%);
  transition: transform 650ms var(--ease);
  pointer-events: none;
  mix-blend-mode: screen;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -10px 18px rgba(0, 0, 0, 0.18),
    0 18px 36px -12px rgba(176, 65, 62, 0.7),
    0 0 0 1px rgba(176, 65, 62, 0.4);
}

.primary-btn:hover::after {
  transform: translateX(120%);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.3),
    0 6px 16px -8px rgba(176, 65, 62, 0.55);
}

/* Sumi / urushi ink — secondary */
.secondary-btn {
  color: var(--gold-hi);
  background: var(--metal-ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -8px 14px rgba(0, 0, 0, 0.3),
    0 8px 20px -8px rgba(14, 16, 20, 0.55),
    0 0 0 1px rgba(176, 138, 63, 0.3);
}

.secondary-btn::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  border: 1px solid rgba(212, 175, 106, 0.18);
  pointer-events: none;
}

.secondary-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 32px -10px rgba(14, 16, 20, 0.7),
    0 0 0 1px rgba(212, 175, 106, 0.55);
  color: #fff1c8;
}

.secondary-btn:active {
  transform: translateY(0);
}

/* Washi ghost — tertiary */
.ghost-btn {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 10px 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.ghost-btn:hover {
  transform: translateY(-1px);
  background: var(--surface-hi);
  border-color: var(--line-gold);
}

.ghost-btn:active {
  transform: translateY(0);
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
}

.icon-btn > svg {
  width: 18px;
  height: 18px;
}

/* Theme toggle — day/night swap via [data-theme] */
.theme-toggle-btn .icon-sun {
  display: inline-block;
}
.theme-toggle-btn .icon-moon {
  display: none;
}
html[data-theme="dark"] .theme-toggle-btn .icon-sun {
  display: none;
}
html[data-theme="dark"] .theme-toggle-btn .icon-moon {
  display: inline-block;
}

/* Language switcher — globe dropdown in topbar */
.lang-switcher {
  position: relative;
  display: inline-flex;
}
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  min-width: 148px;
  background: var(--surface-elevated, #fff7ec);
  border: 1px solid color-mix(in srgb, var(--seal, #b0413e) 28%, transparent);
  border-radius: 10px;
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 60%, transparent) inset,
    0 12px 28px -16px rgba(40, 22, 18, 0.45),
    0 4px 12px -8px rgba(40, 22, 18, 0.3);
  z-index: 60;
  backdrop-filter: blur(4px);
}
html[data-theme="dark"] .lang-menu {
  background: color-mix(in srgb, #1a1c22 88%, transparent);
  border-color: color-mix(in srgb, #d4a05a 22%, transparent);
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 6%, transparent) inset,
    0 14px 30px -16px rgba(0, 0, 0, 0.7),
    0 4px 14px -8px rgba(0, 0, 0, 0.55);
}
.lang-menu.hidden {
  display: none;
}
.lang-menu li {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--ink, #2b1e16);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}
.lang-menu li:hover {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--seal, #b0413e) 8%, transparent) 0%,
    color-mix(in srgb, var(--seal, #b0413e) 14%, transparent) 50%,
    color-mix(in srgb, var(--seal, #b0413e) 8%, transparent) 100%
  );
  color: var(--seal, #b0413e);
}
html[data-theme="dark"] .lang-menu li {
  color: #f4ead7;
}
html[data-theme="dark"] .lang-menu li:hover {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, #d4a05a 10%, transparent) 0%,
    color-mix(in srgb, #d4a05a 18%, transparent) 50%,
    color-mix(in srgb, #d4a05a 10%, transparent) 100%
  );
  color: #f8d18a;
}
.lang-menu li.is-current {
  font-weight: 600;
  color: var(--seal, #b0413e);
}
.lang-menu li.is-current::before {
  content: "·";
  font-weight: 700;
  font-size: 1.2em;
  line-height: 0.8;
  margin-right: 2px;
}
html[data-theme="dark"] .lang-menu li.is-current {
  color: #f8d18a;
}

/* -------- 7. Cards & panels ------------------------------------------- */

.panel,
.hero-card,
.metric-card,
.mini-card,
.scanner-card,
.code-box,
.hero-copy-card,
.hero-banner-card,
.footer-banner-card,
.clock-card,
.notice-card,
.menu-sheet,
.history-modal-card,
.challenge-panel {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift-2);
  isolation: isolate;
  transition:
    transform var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease);
}

/* Backlit top highlight — "light from above" */
.panel::before,
.hero-card::before,
.hero-copy-card::before,
.hero-banner-card::before,
.footer-banner-card::before,
.clock-card::before,
.notice-card::before,
.scanner-card::before,
.metric-card::before,
.menu-sheet::before,
.history-modal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.35) 0%,
    rgba(255, 255, 255, 0) 40%
  );
  pointer-events: none;
  z-index: -1;
}

html[data-theme="dark"] .panel::before,
html[data-theme="dark"] .hero-card::before,
html[data-theme="dark"] .hero-copy-card::before,
html[data-theme="dark"] .hero-banner-card::before,
html[data-theme="dark"] .footer-banner-card::before,
html[data-theme="dark"] .clock-card::before,
html[data-theme="dark"] .notice-card::before,
html[data-theme="dark"] .scanner-card::before,
html[data-theme="dark"] .metric-card::before,
html[data-theme="dark"] .menu-sheet::before,
html[data-theme="dark"] .history-modal-card::before {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0) 40%
  );
}

.panel,
.hero-card {
  padding: 26px;
}

.panel.inset {
  padding: 22px;
  background: var(--surface-hi);
  box-shadow: var(--shadow-lift-1);
  border-radius: var(--radius-md);
}

/* Corner hairline ornaments — reserved for hero / notice */
.metal-corners::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid transparent;
  border-image: var(--metal-gold) 1;
  clip-path: polygon(
    0 0, 14px 0, 14px 1px, 1px 1px, 1px 14px, 0 14px,
    0 100%, 14px 100%, 14px calc(100% - 1px), 1px calc(100% - 1px), 1px calc(100% - 14px), 0 calc(100% - 14px),
    0 0,
    100% 0, calc(100% - 14px) 0, calc(100% - 14px) 1px, calc(100% - 1px) 1px, calc(100% - 1px) 14px, 100% 14px,
    100% 100%, calc(100% - 14px) 100%, calc(100% - 14px) calc(100% - 1px), calc(100% - 1px) calc(100% - 1px), calc(100% - 1px) calc(100% - 14px), 100% calc(100% - 14px)
  );
  pointer-events: none;
  opacity: 0.65;
}

/* -------- 8. Login, onboarding ---------------------------------------- */

#login-panel {
  padding: 40px 32px;
  text-align: left;
  background:
    radial-gradient(
      ellipse 80% 60% at 100% 0%,
      rgba(176, 65, 62, 0.08),
      transparent 60%
    ),
    var(--surface-hi);
}

#login-panel h2 {
  font-size: clamp(28px, 4vw, 40px);
  margin-bottom: 12px;
}

#login-panel .muted {
  max-width: 52ch;
  margin-bottom: 24px;
  font-size: 15px;
}

#login-panel .button-row {
  margin-top: 12px;
}
#login-panel .button-row .primary-btn {
  width: 100%;
}

#login-panel::before {
  /* keep the base backlit gradient from cards */
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 28px 0 18px;
  color: color-mix(in srgb, var(--ink, #2b1e16) 50%, transparent);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--seal, #b0413e) 26%, transparent) 50%,
    transparent
  );
}
html[data-theme="dark"] .login-divider {
  color: color-mix(in srgb, #f4ead7 50%, transparent);
}
html[data-theme="dark"] .login-divider::before,
html[data-theme="dark"] .login-divider::after {
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, #d4a05a 30%, transparent) 50%,
    transparent
  );
}

.email-login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}
.email-login-form .eyebrow {
  margin: 0 0 -4px;
}
.email-login-form input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-md, 14px);
  border: 1px solid var(--line-strong, rgba(176, 67, 62, 0.28));
  background: var(--surface-elevated, #fff7ec);
  color: var(--ink, #2b1e16);
  font-size: 16px;
  letter-spacing: 0.02em;
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 55%, transparent) inset,
    0 2px 6px -4px rgba(40, 22, 18, 0.18);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.email-login-form input::placeholder {
  color: color-mix(in srgb, var(--ink, #2b1e16) 38%, transparent);
}
.email-login-form input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--cinnabar, #b0413e) 60%, transparent);
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 60%, transparent) inset,
    0 0 0 3px color-mix(in srgb, var(--cinnabar, #b0413e) 18%, transparent);
}
.email-login-form #code-input {
  font-family: "JetBrains Mono", Menlo, monospace;
  font-size: 22px;
  letter-spacing: 0.4em;
  text-align: center;
  padding: 14px;
}
.email-login-form button[type="submit"] {
  align-self: stretch;
  width: 100%;
}
.email-login-form #email-back-btn {
  align-self: center;
  font-size: 13px;
}
.email-hint {
  margin: -2px 0 2px;
  font-size: 13px;
  line-height: 1.5;
}
.email-sent-label {
  margin: 0;
  font-size: 13.5px;
}
html[data-theme="dark"] .email-login-form input {
  background: color-mix(in srgb, #1a1c22 80%, transparent);
  border-color: color-mix(in srgb, #d4a05a 26%, transparent);
  color: #f4ead7;
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 6%, transparent) inset,
    0 2px 6px -4px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] .email-login-form input:focus {
  border-color: color-mix(in srgb, #f8d18a 60%, transparent);
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 8%, transparent) inset,
    0 0 0 3px color-mix(in srgb, #d4a05a 22%, transparent);
}

.role-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.role-card {
  position: relative;
  display: block;
  text-align: left;
  padding: 22px 22px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: var(--surface-hi);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  box-shadow: var(--shadow-lift-1);
  transition:
    transform var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease);
  isolation: isolate;
  overflow: hidden;
}

.role-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.45) 0%,
    transparent 40%
  );
  pointer-events: none;
  z-index: -1;
}

.role-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--metal-gold);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease);
}

.role-card .eyebrow {
  margin-bottom: 12px;
}

.role-card strong {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}

.role-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.65;
}

.role-card:hover,
.role-card.is-active {
  transform: translateY(-2px);
  border-color: var(--line-gold);
  box-shadow: var(--shadow-lift-2), var(--glow-gold);
}

.role-card:hover::after,
.role-card.is-active::after {
  opacity: 0.85;
}

/* -------- 9. Dashboard — clock hero, clock card ---------------------- */

.app-home-shell {
  display: grid;
  gap: 20px;
}

.hero-band {
  display: grid;
  gap: 18px;
}

.hero-copy-card {
  padding: 28px 30px;
  background:
    radial-gradient(
      ellipse 80% 60% at 0% 0%,
      rgba(176, 65, 62, 0.09),
      transparent 60%
    ),
    var(--surface);
  display: grid;
  gap: 10px;
  align-content: start;
}

.hero-copy-card h2 {
  font-size: clamp(28px, 4.2vw, 40px);
  letter-spacing: -0.02em;
}

.hero-copy-card .muted {
  font-size: 14px;
}

.hero-banner-card,
.footer-banner-card {
  padding: 20px;
  display: grid;
  gap: 16px;
  background:
    linear-gradient(
      135deg,
      rgba(176, 138, 63, 0.07),
      rgba(176, 65, 62, 0.04)
    ),
    var(--surface);
}

.banner-copy {
  display: grid;
  gap: 8px;
  align-content: center;
}

.banner-label {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  background: var(--metal-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.banner-copy strong {
  font-family: var(--font-serif);
  font-size: clamp(18px, 2.4vw, 22px);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.banner-media {
  display: block;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.banner-image {
  width: 100%;
  min-height: 120px;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-hi);
}

/* Dashboard header — slim company-name strip replacing clock-hero + MY COMPANY card */
.dashboard-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(
      ellipse 80% 60% at 0% 0%,
      rgba(176, 65, 62, 0.08),
      transparent 60%
    ),
    var(--surface-hi);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift-1);
  position: relative;
  overflow: hidden;
}

.dashboard-header::after {
  content: "";
  position: absolute;
  top: 0;
  left: 22px;
  right: 22px;
  height: 1px;
  background: var(--metal-gold);
  opacity: 0.55;
}

.dashboard-header > .topbar-seal {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  font-size: 24px;
}

.dashboard-header-copy {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.dashboard-header-copy .eyebrow {
  margin: 0 0 2px;
}

.dashboard-header-copy #company-title {
  font-family: var(--font-serif);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ink);
  margin: 0;
  word-break: break-word;
}

.dashboard-header-copy #membership-role {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 2px 0 0;
  letter-spacing: 0.04em;
}

/* ==================================================================
   Pairing-code card (owner-only flagship) — the key to letting
   employees join. Displayed prominently right under the dashboard
   header. Visual: cinnabar + gold + dashed frame to signal "credential".
   ================================================================== */

.pairing-card {
  position: relative;
  padding: 28px 32px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(176, 65, 62, 0.12), transparent 60%),
    radial-gradient(ellipse 40% 60% at 100% 100%, rgba(176, 138, 63, 0.10), transparent 60%),
    var(--surface-hi);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift-3);
  isolation: isolate;
  overflow: hidden;
  display: grid;
  gap: 16px;
}

.pairing-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, transparent 40%);
  pointer-events: none;
  z-index: -1;
}

html[data-theme="dark"] .pairing-card::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, transparent 40%);
}

.pairing-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 32px;
  right: 32px;
  height: 2px;
  background: var(--metal-gold);
  opacity: 0.85;
  border-radius: 2px;
}

.pairing-head {
  display: grid;
  gap: 4px;
}

.pairing-head h3 {
  font-family: var(--font-serif);
  font-size: clamp(22px, 2.8vw, 28px);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 4px 0 0;
}

.pairing-code-row {
  display: flex;
  align-items: stretch;
  gap: 14px;
  flex-wrap: wrap;
}

.pairing-code {
  flex: 1 1 auto;
  font-family: var(--font-mono);
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 700;
  letter-spacing: 0.22em;
  line-height: 1.1;
  color: var(--cinnabar);
  background: var(--bg);
  padding: 20px 24px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--line-gold);
  text-align: center;
  user-select: all;
  -webkit-user-select: all;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

html[data-theme="dark"] .pairing-code {
  text-shadow: none;
  background: rgba(14, 16, 20, 0.6);
}

.pairing-card .icon-btn {
  flex: 0 0 56px;
  width: 56px;
  height: auto;
  align-self: stretch;
  border-radius: var(--radius-md);
}

.pairing-card .icon-btn svg {
  width: 22px;
  height: 22px;
}

.pairing-hint {
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-soft);
  padding-left: 16px;
  border-left: 2px solid var(--line-gold);
}

.pairing-hint strong {
  color: var(--cinnabar);
  font-weight: 700;
}

.pairing-card > .button-row {
  margin-top: 4px;
}

@media (max-width: 640px) {
  .pairing-card { padding: 22px 20px; }
  .pairing-card::after { left: 20px; right: 20px; }
  .pairing-code { padding: 16px 14px; letter-spacing: 0.16em; }
  .pairing-card .icon-btn { flex: 0 0 auto; width: 100%; height: 44px; }
}

/* Clock card (attendance) */
.clock-stack {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}

/* Announcement is the flagship — show first, clock-in below */
.clock-stack > #notice-card {
  order: 1;
}
.clock-stack > #attendance-panel {
  order: 2;
}

.clock-card {
  padding: 24px;
  display: grid;
  gap: 18px;
}

.clock-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}

.clock-card-head > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.clock-card-head h3 {
  font-size: clamp(22px, 2.6vw, 28px);
  margin: 0;
}

/* Scanner */
.scanner-card {
  padding: 20px;
  display: grid;
  gap: 16px;
  background: var(--surface-hi);
}

.qr-stage {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--sumi);
  min-height: 280px;
}

html[data-theme="dark"] .qr-stage {
  background: #05060a;
}

.qr-stage::before,
.qr-stage::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border: 2px solid var(--gold-hi);
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 0 6px rgba(226, 195, 122, 0.55));
  animation: scanner-pulse 2.8s var(--ease) infinite;
}

.qr-stage::before {
  top: 10px;
  left: 10px;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 6px;
}

.qr-stage::after {
  bottom: 10px;
  right: 10px;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: 6px;
}

@keyframes scanner-pulse {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

.qr-reader {
  min-height: 280px;
  border-radius: var(--radius-md);
}

.qr-reader video,
.qr-reader img {
  border-radius: var(--radius-sm);
}

/* Challenge panel + frozen frame */
.challenge-panel {
  padding: 22px;
  background: var(--surface-hi);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow-lift-1);
}

.frozen-frame {
  position: relative;
  padding: 10px;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift-1);
  transform: rotate(-0.25deg);
}

html[data-theme="dark"] .frozen-frame {
  background: #1c1f26;
}

.frozen-image {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 0;
  display: block;
}

/* Hide the polaroid frame when the image inside is hidden */
.frozen-frame:has(> .frozen-image.hidden) {
  display: none;
}

#totp-code {
  font-family: var(--font-mono);
  font-size: clamp(22px, 3vw, 28px);
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* -------- 10. Notice card (FLAGSHIP) --------------------------------- */

.notice-card {
  padding: 32px 32px 28px;
  display: grid;
  gap: 18px;
  background: var(--surface-hi);
  box-shadow: var(--shadow-lift-3);
  border: 1px solid var(--line-strong);
  transition:
    transform var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease);
}

.notice-card:hover {
  transform: translateY(-2px);
  box-shadow:
    var(--shadow-lift-3),
    0 0 0 1px var(--line-gold);
}

.notice-card > *:not(.notice-head)::before {
  /* placeholder, nothing */
}

/* Top metallic inlay + shimmer */
.notice-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--gold-lo) 0%,
    var(--gold) 18%,
    var(--gold-hi) 30%,
    var(--gold) 46%,
    var(--gold-hi) 62%,
    var(--gold) 80%,
    var(--gold-lo) 100%
  );
  background-size: 200% 100%;
  background-position: 0% 50%;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  animation: notice-shimmer 8s var(--ease) infinite;
  opacity: 0.95;
  filter: drop-shadow(0 0 3px rgba(226, 195, 122, 0.35));
  pointer-events: none;
}

@keyframes notice-shimmer {
  0%, 20% {
    background-position: 0% 50%;
  }
  55%, 100% {
    background-position: -200% 50%;
  }
}

/* Four gold L-shaped corner ornaments — notice exclusivity */
.notice-card > .corner-tl,
.notice-card > .corner-tr,
.notice-card > .corner-bl,
.notice-card > .corner-br {
  display: none; /* reserved for future SVG corners */
}

/* Head row */
.notice-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-top: 4px;
}

.notice-head > div {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.notice-head .eyebrow {
  position: relative;
  padding-left: 14px;
}

.notice-head .eyebrow::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--metal-cinnabar);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 2px 6px rgba(176, 65, 62, 0.4);
}

#announcement-title {
  font-family: var(--font-serif);
  font-size: clamp(26px, 3.6vw, 38px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
  position: relative;
  padding-bottom: 12px;
  margin: 0;
}

#announcement-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 42px;
  height: 2px;
  background: var(--metal-gold);
  border-radius: 2px;
}

#announcement-body,
.notice-card p.muted {
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink-soft);
  padding-left: 16px;
  border-left: 2px solid var(--line-gold);
  margin: 0;
}

.notice-ad {
  display: block;
  margin-top: 4px;
  padding: 10px;
  background: #fffdf7;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift-1);
}

html[data-theme="dark"] .notice-ad {
  background: #1c1f26;
}

.notice-ad .banner-image {
  max-height: 200px;
  border-radius: var(--radius-sm);
}

/* -------- 11. Status pills -------------------------------------------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--line-gold);
  color: var(--gold);
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 4px rgba(176, 138, 63, 0.6);
}

.status-pill.is-display {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
}

.status-pill.is-display::before {
  background: var(--cinnabar);
  box-shadow: 0 0 4px rgba(176, 65, 62, 0.55);
}

/* -------- 12. Forms --------------------------------------------------- */

.form-block,
.form-grid,
.check-grid {
  display: grid;
  gap: 14px;
}

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

.form-grid.single {
  grid-template-columns: 1fr;
}

.check-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0;
  gap: 10px 18px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  background: var(--surface-hi);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-inset-soft);
  transition:
    border-color var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease),
    background var(--dur-base) var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-faint);
}

input:hover,
textarea:hover {
  border-color: var(--line-gold);
}

input:focus,
textarea:focus {
  border-color: var(--cinnabar);
  outline: none;
  box-shadow:
    var(--shadow-inset-soft),
    0 0 0 3px rgba(176, 65, 62, 0.14);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  flex: 0 0 18px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-hi);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-inset-soft);
}

input[type="checkbox"]:checked {
  background: var(--metal-cinnabar);
  border-color: var(--cinnabar);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 0 0 1px rgba(176, 65, 62, 0.35);
}

input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 6px;
  height: 11px;
  border: 2px solid #fff5e8;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg);
}

.form-block label,
.form-grid label {
  /* already grid-like */
}

/* -------- 13. Dividers, section-heads -------------------------------- */

.divider {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--line-strong) 15%,
    var(--line-strong) 85%,
    transparent 100%
  );
  margin: 20px 0;
  border: 0;
}

.metal-line {
  height: 1px;
  background: var(--metal-gold);
  opacity: 0.6;
  margin: 20px 0;
  border-radius: 1px;
}

.section-head,
.company-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.section-head > div:first-child,
.company-header > div:first-child {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}

/* -------- 14. Grid helpers ------------------------------------------- */

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

.grid-two.tight {
  gap: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}

.display-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

#app-panel {
  display: grid;
  gap: 22px;
}

#app-panel > .grid-two {
  grid-template-columns: 1fr;
}

#onboarding-panel,
#dashboard-panel,
#display-panel {
  width: 100%;
}

/* -------- 15. Owner panel & code boxes ------------------------------- */

.code-box {
  padding: 16px 20px;
  min-width: 140px;
  background: var(--surface-hi);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift-1);
  display: grid;
  gap: 4px;
}

.code-box span {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.code-box strong {
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.1em;
  color: var(--cinnabar);
}

.mini-card {
  padding: 20px;
  display: grid;
  gap: 8px;
  background: var(--surface-hi);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift-1);
}

.mini-card span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.static-qr-box {
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px dashed var(--line-strong);
  box-shadow: var(--shadow-inset-soft);
}

html[data-theme="dark"] .static-qr-box {
  background: #fffdf7;
}

.static-qr-box canvas,
.static-qr-box img {
  max-width: 100%;
  height: auto;
}

#static-qr-value {
  font-family: var(--font-mono);
  color: var(--cinnabar);
  letter-spacing: 0.08em;
}

/* -------- 16. Member list -------------------------------------------- */

.member-list {
  display: grid;
  gap: 10px;
}

.member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-hi);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift-1);
}

.member-row strong {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
}

.member-row small {
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.member-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* -------- 17. History table ------------------------------------------ */

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

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.history-table th,
.history-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-sans);
}

.history-table th {
  position: sticky;
  top: 0;
  background: var(--surface-hi);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line-strong);
}

.history-table tbody tr {
  transition: background var(--dur-fast) var(--ease);
}

.history-table tbody tr:hover {
  background: rgba(176, 138, 63, 0.05);
}

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

/* -------- 18. Toast --------------------------------------------------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  max-width: min(380px, calc(100% - 48px));
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--metal-ink);
  color: var(--gold-hi);
  font-size: 14px;
  font-weight: 500;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 48px -12px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(212, 175, 106, 0.35);
  animation: toast-in 240ms var(--ease);
  isolation: isolate;
}

.toast::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 1px;
  background: var(--metal-gold);
  opacity: 0.6;
}

@keyframes toast-in {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -------- 19. Menu sheet & modals ------------------------------------ */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(9, 12, 18, 0.48);
  backdrop-filter: blur(10px) saturate(0.95);
  -webkit-backdrop-filter: blur(10px) saturate(0.95);
  animation: backdrop-in 220ms var(--ease);
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.menu-sheet {
  position: fixed;
  left: 16px;
  right: auto;
  bottom: 16px;
  z-index: 40;
  width: min(420px, calc(100% - 32px));
  padding: 22px;
  border-radius: var(--radius-xl);
  background: var(--surface-hi);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift-3);
  animation: sheet-up 280ms var(--ease);
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.menu-sheet-actions {
  display: grid;
  gap: 12px;
}

.menu-sheet .role-card {
  padding: 16px 18px;
}

.menu-sheet .role-card strong {
  font-size: 18px;
  margin-bottom: 4px;
}

.menu-sheet .role-card p {
  font-size: 13px;
}

.history-modal,
#profile-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  padding: 24px;
  display: grid;
  place-items: center;
  animation: backdrop-in 220ms var(--ease);
}

.history-modal-card {
  position: relative;
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 28px;
  border-radius: var(--radius-xl);
  background: var(--surface-hi);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift-3);
  animation: sheet-up 280ms var(--ease);
}

/* -------- 20. Landing page ------------------------------------------- */

.landing-body {
  overflow-x: hidden;
}

.landing-shell {
  padding: 56px 0 80px;
  display: grid;
  gap: 40px;
}

.landing-body .hero-card {
  margin: 0;
  padding: 60px 56px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 40px;
  background:
    radial-gradient(
      ellipse 60% 80% at 0% 0%,
      rgba(176, 65, 62, 0.08),
      transparent 62%
    ),
    radial-gradient(
      ellipse 40% 60% at 100% 100%,
      rgba(176, 138, 63, 0.08),
      transparent 62%
    ),
    var(--surface-hi);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
}

.landing-body .hero-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 56px;
  right: 56px;
  height: 1px;
  background: var(--metal-gold);
  opacity: 0.55;
}

.hero-copy {
  display: grid;
  gap: 18px;
  align-content: center;
}

.hero-copy h1 {
  font-size: clamp(40px, 6.5vw, 72px);
  line-height: 1.02;
  font-weight: 600;
  max-width: 14ch;
}

.hero-text {
  max-width: 52ch;
  font-size: 17px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.hero-panel {
  display: grid;
  gap: 16px;
  align-content: center;
}

.metric-card {
  padding: 22px 24px;
  display: grid;
  gap: 6px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift-1);
}

.metric-card span {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  background: var(--metal-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.metric-card strong {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.landing-footer {
  margin-top: 40px;
  padding: 32px 0;
  text-align: center;
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  position: relative;
}

.landing-footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 1px;
  background: var(--metal-gold);
  opacity: 0.55;
}

/* -------- 21. Screen / static screen --------------------------------- */

.screen-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--gold-hi);
  background:
    radial-gradient(
      ellipse 50% 40% at 50% 0%,
      rgba(176, 138, 63, 0.1),
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 40% at 50% 100%,
      rgba(176, 65, 62, 0.08),
      transparent 60%
    ),
    linear-gradient(180deg, #0a0c11 0%, #14171d 100%);
  background-attachment: fixed;
}

.screen-shell {
  position: relative;
  min-height: 100vh;
  width: min(1200px, calc(100% - 48px));
  display: grid;
  place-items: center;
  text-align: center;
  padding: 48px 0;
  gap: 28px;
}

.screen-shell > .eyebrow {
  color: transparent;
  background: var(--metal-gold);
  -webkit-background-clip: text;
  background-clip: text;
  font-size: 13px;
  letter-spacing: 0.32em;
}

#screen-company-name,
#static-screen-company-name,
.screen-shell h1 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--metal-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0;
}

.screen-qr {
  position: relative;
  width: min(60vh, 560px);
  height: min(60vh, 560px);
  max-width: calc(100vw - 64px);
  max-height: calc(100vw - 64px);
  padding: 24px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 0 0 1px var(--gold),
    0 0 0 6px rgba(176, 138, 63, 0.18),
    0 40px 80px -20px rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
}

.screen-qr canvas,
.screen-qr img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Gold L-corners around QR */
.screen-qr::before,
.screen-qr::after {
  content: "";
  position: absolute;
  width: 46px;
  height: 46px;
  border: 3px solid var(--gold-hi);
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(226, 195, 122, 0.55));
}

.screen-qr::before {
  top: -18px;
  left: -18px;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 8px;
}

.screen-qr::after {
  bottom: -18px;
  right: -18px;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: 8px;
}

.screen-code {
  font-family: var(--font-serif);
  font-size: clamp(96px, 14vw, 200px);
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: var(--metal-gold);
  background-size: 200% 100%;
  background-position: 0% 50%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: screen-code-shimmer 6s var(--ease) infinite;
  text-shadow: 0 0 48px rgba(226, 195, 122, 0.15);
  padding: 0 8px;
}

@keyframes screen-code-shimmer {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.screen-code-static {
  font-family: var(--font-mono);
  font-size: clamp(22px, 4vw, 36px);
  letter-spacing: 0.1em;
  word-break: break-all;
  color: var(--gold-hi);
  background: rgba(20, 23, 29, 0.65);
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-gold);
}

.screen-hint {
  max-width: 38ch;
  margin: 0 auto;
  font-size: clamp(14px, 1.6vw, 18px);
  line-height: 1.75;
  color: rgba(234, 228, 215, 0.55);
}

.screen-body .muted {
  color: rgba(234, 228, 215, 0.4);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
}

/* Screen corner ornaments */
.screen-body::before,
.screen-body::after {
  content: "";
  position: fixed;
  width: 60px;
  height: 60px;
  border: 1px solid var(--gold-hi);
  opacity: 0.5;
  pointer-events: none;
  z-index: 1;
}

.screen-body::before {
  top: 24px;
  left: 24px;
  border-right: 0;
  border-bottom: 0;
}

.screen-body::after {
  bottom: 24px;
  right: 24px;
  border-left: 0;
  border-top: 0;
}

/* -------- 22. Challenge hint / supporting text ------------------------ */

.notice-card .status-pill.is-display,
.notice-card .status-pill {
  margin-top: 4px;
}

/* -------- 23. Responsive ---------------------------------------------- */

@media (min-width: 901px) {
  .hero-band {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
    align-items: stretch;
  }

  .hero-banner-card,
  .footer-banner-card {
    grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
    align-items: center;
  }

  .hero-banner-card .banner-copy,
  .footer-banner-card .banner-copy {
    order: 2;
  }

  .hero-banner-card .banner-media,
  .footer-banner-card .banner-media {
    order: 1;
  }

  .challenge-panel .grid-two {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
  }

  .topbar-ad {
    order: 3;
    flex-basis: 100%;
    margin: 4px 0 0;
  }

  .topbar-ad-caption {
    display: none;
  }

  .hero-card,
  .grid-two,
  .form-grid,
  .check-grid,
  .role-picker,
  .landing-body .hero-card {
    grid-template-columns: 1fr;
  }

  .landing-body .hero-card {
    padding: 40px 28px;
  }

  .section-head,
  .company-header {
    flex-direction: column;
  }

  .clock-card-head,
  .notice-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .landing-shell,
  .app-shell,
  .screen-shell {
    width: min(100%, calc(100% - 20px));
  }

  .app-body .topbar {
    width: min(100%, calc(100% - 20px));
    padding: 14px 16px;
  }

  .topbar-title {
    font-size: 20px;
  }

  .panel,
  .hero-card,
  .hero-copy-card,
  .hero-banner-card,
  .clock-card,
  .notice-card,
  .footer-banner-card,
  .history-modal-card,
  #login-panel {
    border-radius: var(--radius-lg);
    padding: 20px;
  }

  .banner-image {
    min-height: 116px;
    max-height: 160px;
  }

  .menu-sheet {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 10px;
    padding: 18px;
    border-radius: 24px;
  }

  .history-modal,
  #profile-modal {
    padding: 12px;
  }

  .history-modal-card {
    padding: 20px;
    border-radius: 22px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    max-width: calc(100% - 24px);
  }

  .landing-body .hero-card::after,
  .topbar::after {
    left: 20px;
    right: 20px;
  }

  .screen-body::before,
  .screen-body::after {
    width: 40px;
    height: 40px;
    top: 12px;
    left: 12px;
  }
  .screen-body::after {
    top: auto;
    left: auto;
    bottom: 12px;
    right: 12px;
  }
}

/* -------- 24. Reduced motion ---------------------------------------- */

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

  .primary-btn::after,
  .qr-stage::before,
  .qr-stage::after,
  .notice-card::after,
  .screen-code {
    animation: none !important;
  }
}

/* -------- 25. Utilities --------------------------------------------- */

[aria-hidden="true"] {
  /* decorative; respect display: hidden */
}

.kyoto-mark {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--metal-cinnabar);
  color: #fff5e8;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -10px 22px rgba(0, 0, 0, 0.25),
    0 10px 24px -10px rgba(176, 65, 62, 0.55);
  position: relative;
}

.kyoto-mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* ==================================================================
   Portal (Superuser console)
   ================================================================== */

.portal-body {
  min-height: 100vh;
}

.portal-shell {
  padding: 40px 0 80px;
  display: grid;
  gap: 32px;
  max-width: min(1080px, calc(100% - 32px));
}

.portal-hero {
  position: relative;
  padding: 48px 40px 44px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(
      ellipse 70% 80% at 0% 0%,
      rgba(176, 65, 62, 0.09),
      transparent 62%
    ),
    radial-gradient(
      ellipse 40% 60% at 100% 100%,
      rgba(176, 138, 63, 0.09),
      transparent 62%
    ),
    var(--surface-hi);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift-2);
  isolation: isolate;
  overflow: hidden;
}

.portal-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, transparent 40%);
  pointer-events: none;
  z-index: -1;
}

html[data-theme="dark"] .portal-hero::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, transparent 40%);
}

.portal-hero::after {
  content: "";
  position: absolute;
  top: 0;
  left: 40px;
  right: 40px;
  height: 1px;
  background: var(--metal-gold);
  opacity: 0.6;
}

.portal-hero h1 {
  font-size: clamp(32px, 4.4vw, 48px);
  font-weight: 600;
  margin: 12px 0 14px;
  letter-spacing: -0.02em;
}

.portal-hero .hero-text {
  max-width: 60ch;
  font-size: 16px;
  color: var(--ink-soft);
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.portal-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 22px 22px 22px 20px;
  background: var(--surface-hi);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift-1);
  color: var(--ink);
  text-decoration: none;
  transition:
    transform var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease);
  isolation: isolate;
  overflow: hidden;
  cursor: pointer;
}

.portal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, transparent 40%);
  pointer-events: none;
  z-index: -1;
}

html[data-theme="dark"] .portal-card::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, transparent 40%);
}

.portal-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--metal-gold);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease);
}

.portal-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-gold);
  box-shadow: var(--shadow-lift-2), var(--glow-gold);
}

.portal-card:hover::after {
  opacity: 0.85;
}

.portal-card[aria-disabled="true"] {
  opacity: 0.72;
  cursor: not-allowed;
}

.portal-card[aria-disabled="true"]:hover {
  transform: none;
  box-shadow: var(--shadow-lift-1);
  border-color: var(--line-strong);
}

.portal-card[aria-disabled="true"]:hover::after {
  opacity: 0;
}

.portal-card-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--metal-ink);
  color: var(--gold-hi);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 6px 14px -6px rgba(14, 16, 20, 0.5);
}

.portal-card-icon svg {
  width: 24px;
  height: 24px;
}

.portal-card--primary .portal-card-icon {
  background: var(--metal-cinnabar);
  color: #fff5e8;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 6px 14px -6px rgba(176, 65, 62, 0.6);
}

.portal-card-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.portal-card-body h3 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  margin: 2px 0 4px;
}

.portal-card-body p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0;
}

.portal-card-label {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  background: var(--metal-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.portal-card-arrow {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--ink-faint);
  transition: transform var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

.portal-card:hover .portal-card-arrow {
  color: var(--cinnabar);
  transform: translateX(3px);
}

.portal-card[aria-disabled="true"] .portal-card-arrow {
  opacity: 0.4;
}

.portal-footer-note {
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift-1);
  display: grid;
  gap: 8px;
}

.portal-footer-note p:last-child {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.75;
  margin: 0;
}

.portal-footer-note code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 8px;
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--cinnabar);
}

@media (max-width: 640px) {
  .portal-hero {
    padding: 32px 22px 28px;
  }
  .portal-hero::after {
    left: 22px;
    right: 22px;
  }
  .portal-card {
    grid-template-columns: auto 1fr;
  }
  .portal-card-arrow {
    display: none;
  }
}

/* Empty-state seal for notice card */
.notice-empty {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 22px 0 8px;
  text-align: center;
}

.notice-empty .kyoto-mark {
  width: 64px;
  height: 64px;
  font-size: 32px;
}

.notice-empty p {
  color: var(--ink-faint);
  font-size: 13px;
  letter-spacing: 0.08em;
}

/* Owner mode tabs (公司模式 / 員工模式) */
.mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin: 0 0 18px;
  background: var(--surface-hi);
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .mode-tabs {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.mode-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.mode-tab:hover {
  color: var(--ink);
}

.mode-tab.active {
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .mode-tab.active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ========================================================================
   Owner panel re-design — Zones, attendance method panel, toggles, modal
   ======================================================================== */

/* -------- Zones -------- */

.owner-zone {
  display: grid;
  gap: 22px;
  margin-top: 28px;
}

.owner-zone:first-of-type {
  margin-top: 18px;
}

.owner-zone-head {
  display: grid;
  gap: 4px;
  padding: 0 4px;
}

.owner-zone-head h3 {
  font-family: var(--font-serif);
  font-size: 26px;
  margin: 0;
  letter-spacing: 0.01em;
}

.owner-zone-head .eyebrow {
  background: var(--metal-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

.owner-zone .grid-two,
.owner-zone .zone-grid-three {
  align-items: stretch;
}

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

@media (max-width: 960px) {
  .zone-grid-three {
    grid-template-columns: 1fr;
  }
}

.zone-subpanel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.zone-subpanel h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: 0.01em;
}

.zone-subpanel .eyebrow {
  margin: 0;
  opacity: 0.85;
}

.zone-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  padding: 4px 0 0;
}

.zone-action-row .primary-btn,
.zone-action-row .secondary-btn,
.zone-action-row .ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* -------- Zone divider -------- */

.zone-divider {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 32px 0 4px;
  height: 28px;
}

.zone-divider::before,
.zone-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--line-gold) 50%,
    transparent 100%
  );
}

.zone-divider-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0 14px;
  border-radius: 50%;
  background: var(--metal-cinnabar);
  color: #fff5e8;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -6px 10px rgba(0, 0, 0, 0.18),
    0 8px 18px -8px rgba(176, 65, 62, 0.55);
}

/* -------- 1A · Method panel (focal) -------- */

.method-panel {
  position: relative;
  padding: 28px 28px 24px;
  border-radius: var(--radius-lg);
  background: var(--surface-hi);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 24%),
    linear-gradient(180deg, var(--surface-hi), var(--surface-hi));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift-3);
  overflow: hidden;
  isolation: isolate;
  display: grid;
  gap: 16px;
}

.method-panel::before {
  /* 頂部金線飾 */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--metal-gold);
  opacity: 0.85;
}

.method-panel::after {
  /* 頂部光暈 */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 90px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.35) 0%,
    rgba(255, 255, 255, 0) 100%
  );
  pointer-events: none;
  z-index: -1;
}

[data-theme="dark"] .method-panel::after {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(255, 255, 255, 0) 100%
  );
}

.method-panel-head {
  display: grid;
  gap: 4px;
}

.method-panel-head h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: 0.01em;
}

.method-panel-head .eyebrow {
  margin: 0;
  background: var(--metal-cinnabar);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

/* -------- Method row -------- */

.method-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.method-row:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lift-1);
}

.method-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--metal-cinnabar);
  color: #fff5e8;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -8px 14px rgba(0, 0, 0, 0.22),
    0 6px 16px -6px rgba(176, 65, 62, 0.5);
  flex-shrink: 0;
}

.method-row-icon svg {
  width: 18px;
  height: 18px;
}

.method-row-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.method-row-text strong {
  font-family: var(--font-serif);
  font-size: 17px;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.method-row-text p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.method-row-qr {
  /* QR row 沒有 toggle，只有 ?，segmented 在下一行 */
  grid-template-columns: auto 1fr auto;
}

/* -------- Toggle switch -------- */

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

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

.toggle-track {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-hi);
  border: 1px solid var(--line-strong);
  box-shadow:
    inset 0 1px 2px rgba(26, 29, 36, 0.12),
    inset 0 -1px 0 rgba(255, 255, 255, 0.5);
  transition: background var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease);
  overflow: hidden;
}

[data-theme="dark"] .toggle-track {
  background: rgba(0, 0, 0, 0.32);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.5),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff 0%, #f1ebe0 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 2px 4px rgba(26, 29, 36, 0.18),
    0 6px 12px -6px rgba(26, 29, 36, 0.3);
  transition: transform var(--dur-base) var(--ease),
    background var(--dur-base) var(--ease);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--metal-cinnabar);
  border-color: var(--cinnabar-lo);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 4px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(176, 65, 62, 0.35),
    0 6px 16px -6px rgba(176, 65, 62, 0.55);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(22px);
  background: linear-gradient(180deg, #fff5e8 0%, #f0d8b8 100%);
}

.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid rgba(176, 138, 63, 0.55);
  outline-offset: 2px;
}

/* 光帶掃過效果（只在 :checked 時可見） */
.toggle-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--light-band);
  transform: translateX(-120%);
  transition: transform 700ms var(--ease);
  mix-blend-mode: screen;
  pointer-events: none;
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(120%);
}

/* -------- Method segmented control -------- */

.method-segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow:
    inset 0 1px 2px rgba(26, 29, 36, 0.08),
    inset 0 -1px 0 rgba(255, 255, 255, 0.45);
}

[data-theme="dark"] .method-segmented {
  background: rgba(0, 0, 0, 0.28);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.5),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

.method-segment {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  padding: 10px 14px;
  border-radius: calc(var(--radius-md) - 4px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--dur-base) var(--ease),
    color var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease);
  position: relative;
  overflow: hidden;
}

.method-segment svg {
  width: 16px;
  height: 16px;
}

.method-segment:hover {
  color: var(--ink);
}

.method-segment.active {
  color: #fff5e8;
  background: var(--metal-cinnabar);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -6px 10px rgba(0, 0, 0, 0.2),
    0 6px 14px -8px rgba(176, 65, 62, 0.55);
}

.method-segment.active::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--light-band);
  transform: translateX(-120%);
  animation: segment-shine 1.6s var(--ease);
  mix-blend-mode: screen;
  pointer-events: none;
}

@keyframes segment-shine {
  to {
    transform: translateX(120%);
  }
}

.method-segment:focus-visible {
  outline: 2px solid rgba(176, 138, 63, 0.6);
  outline-offset: 2px;
}

/* -------- Method substack (sub-options for static / dynamic mode) -------- */

.method-substack {
  display: grid;
  gap: 10px;
  padding: 14px 14px 14px 22px;
  margin-left: 12px;
  border-left: 2px solid var(--line-gold);
  background: linear-gradient(
    90deg,
    rgba(176, 138, 63, 0.06) 0%,
    rgba(176, 138, 63, 0) 100%
  );
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  max-height: 1000px;
  overflow: hidden;
  transition: max-height var(--dur-base) var(--ease),
    opacity var(--dur-base) var(--ease),
    padding var(--dur-base) var(--ease),
    margin var(--dur-base) var(--ease);
}

.method-substack[aria-hidden="true"] {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: -8px;
  pointer-events: none;
  border-left-color: transparent;
}

[data-theme="dark"] .method-substack {
  background: linear-gradient(
    90deg,
    rgba(176, 138, 63, 0.08) 0%,
    rgba(176, 138, 63, 0) 100%
  );
}

.method-subrow {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease);
}

.method-subrow:hover {
  background: var(--surface);
}

.method-subrow-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.method-subrow-text strong {
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 0.01em;
}

.method-subrow-text p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.method-subrow .rotate-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
}

.method-subrow .rotate-action svg {
  width: 14px;
  height: 14px;
}

/* -------- Info icon button (?) -------- */

.info-icon-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-hi);
  border: 1px solid var(--line-gold);
  color: var(--gold);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
  padding: 0;
}

.info-icon-btn svg {
  width: 16px;
  height: 16px;
}

.info-icon-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #fff5e8 0%, #f1d9aa 100%);
  color: var(--gold-lo);
  box-shadow: var(--glow-gold);
}

[data-theme="dark"] .info-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--gold-hi);
}

[data-theme="dark"] .info-icon-btn:hover {
  background: linear-gradient(180deg, #4d3d1a 0%, #2a2010 100%);
  color: var(--gold-hi);
}

.info-icon-btn:focus-visible {
  outline: 2px solid rgba(176, 138, 63, 0.6);
  outline-offset: 2px;
}

/* -------- Policy numeric grid (進階參數) -------- */

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

@media (max-width: 720px) {
  .policy-numeric-grid {
    grid-template-columns: 1fr;
  }
}

.policy-numeric-grid label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.policy-numeric-grid label input {
  grid-column: 1 / -1;
  width: 100%;
}

.policy-numeric-grid .suffix {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
}

/* -------- Help modal -------- */

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(9, 12, 18, 0.42);
  backdrop-filter: blur(8px) saturate(0.95);
  -webkit-backdrop-filter: blur(8px) saturate(0.95);
  animation: backdrop-in 220ms var(--ease);
}

.help-modal.hidden {
  display: none;
}

.help-modal-card {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 26px 28px 28px;
  border-radius: var(--radius-xl);
  background: var(--surface-hi);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift-3);
  animation: sheet-up 280ms var(--ease);
}

.help-modal-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--metal-gold);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.help-modal-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 14px;
  margin-bottom: 14px;
}

.help-modal-head .eyebrow {
  margin: 0 0 4px;
  background: var(--metal-cinnabar);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

.help-modal-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: 0.01em;
}

.help-modal-body {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

.help-modal-body strong {
  color: var(--ink);
}

/* -------- Mobile tweaks -------- */

@media (max-width: 720px) {
  .method-panel {
    padding: 22px 18px 18px;
  }

  .method-row {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 10px 12px;
  }

  .method-row .info-icon-btn {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
  }

  .method-row .toggle-switch {
    grid-column: 1 / -1;
    grid-row: 2 / 3;
    justify-self: end;
  }

  .method-row-qr {
    grid-template-columns: auto 1fr auto;
  }

  .method-row-qr .info-icon-btn {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
  }

  .method-segment {
    padding: 10px 8px;
    font-size: 13px;
  }

  .zone-action-row {
    justify-content: stretch;
  }

  .zone-action-row .primary-btn,
  .zone-action-row .secondary-btn {
    flex: 1;
    justify-content: center;
  }

  .help-modal-card {
    padding: 22px 20px;
  }
}

/* ========================================================================
   Zone 4 · Attendance admin (daily table, edit modal, schedule/wages modal)
   ======================================================================== */

.attendance-toolbar {
  padding: 14px 18px;
}

.attendance-date-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.att-date-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.att-date-label input[type="date"] {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
  width: 160px;
}

.att-spacer {
  flex: 1;
}

.attendance-table,
.attendance-edit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.attendance-table thead th,
.attendance-edit-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-strong);
  position: sticky;
  top: 0;
  z-index: 1;
}

.attendance-table tbody td,
.attendance-edit-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
}

.attendance-table tbody tr {
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}

.attendance-table tbody tr:hover {
  background: rgba(176, 65, 62, 0.04);
}

.attendance-table tbody tr:last-child td,
.attendance-edit-table tbody tr:last-child td {
  border-bottom: 0;
}

.att-cell-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 15px;
}

.att-cell-name small {
  display: block;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0;
}

.att-cell-time {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.att-cell-time.empty {
  color: var(--ink-faint);
  font-weight: 400;
}

.att-cell-money {
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: right;
  letter-spacing: 0.02em;
}

.att-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.att-status-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.att-status-chip.ok {
  background: rgba(110, 140, 90, 0.12);
  color: #4d6940;
}
.att-status-chip.ok::before { background: #6e8c5a; }

.att-status-chip.late {
  background: rgba(176, 138, 63, 0.16);
  color: var(--gold-lo);
}
.att-status-chip.late::before { background: var(--gold); }

.att-status-chip.no_clockout {
  background: rgba(176, 138, 63, 0.16);
  color: var(--gold-lo);
}
.att-status-chip.no_clockout::before { background: var(--gold); }

.att-status-chip.absent {
  background: rgba(176, 65, 62, 0.14);
  color: var(--cinnabar-lo);
}
.att-status-chip.absent::before { background: var(--cinnabar); }

[data-theme="dark"] .att-status-chip.ok {
  background: rgba(110, 140, 90, 0.22);
  color: #a7c08e;
}
[data-theme="dark"] .att-status-chip.late,
[data-theme="dark"] .att-status-chip.no_clockout {
  background: rgba(226, 195, 122, 0.18);
  color: var(--gold-hi);
}
[data-theme="dark"] .att-status-chip.absent {
  background: rgba(200, 91, 82, 0.22);
  color: #e88a82;
}

/* Edit modal */

.attendance-edit-card,
.work-rules-card {
  width: min(640px, 100%);
}

.attendance-edit-table input[type="time"],
.attendance-edit-table input[type="text"],
.attendance-edit-table input[type="number"] {
  width: 100%;
}

.att-edit-row-actions {
  display: inline-flex;
  gap: 6px;
}

.att-edit-row-actions .ghost-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.att-edit-row-actions .ghost-btn.delete {
  color: var(--cinnabar);
}

.att-edit-add {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 560px) {
  .att-edit-add {
    grid-template-columns: 1fr;
  }
}

/* Work rules modal tabs */

.work-rules-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 18px;
  background: var(--surface-hi);
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .work-rules-tabs {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.work-rules-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
}

.work-rules-tab.active {
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
}

.work-rules-tab-panel.hidden {
  display: none;
}
