:root {
  color-scheme: light;
  --ink: #173448;
  --ink-soft: #3d5665;
  --paper: #f5f8ef;
  --surface: #fffefa;
  --line: #dce7d3;
  --green: #58c928;
  --green-dark: #347f1c;
  --green-pale: #eaf7df;
  --coral: #ff765d;
  --coral-pale: #fff0eb;
  --danger: #b63d37;
  --shadow: 0 12px 30px rgba(23, 52, 72, .08);
  --radius: 18px;
  --radius-small: 11px;
  --page-width: 1120px;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 90% 0%, rgba(88, 201, 40, .09), transparent 32rem),
    var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

a { color: var(--green-dark); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }

:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

.site-header {
  position: relative;
  z-index: 5;
  background: rgba(255, 254, 250, .94);
  border-bottom: 1px solid rgba(220, 231, 211, .9);
  box-shadow: 0 3px 16px rgba(23, 52, 72, .04);
}

.site-header-inner {
  width: min(calc(100% - 40px), var(--page-width));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -.035em;
}

.brand:hover { color: var(--green-dark); }
.brand-logo { width: 43px; height: 43px; object-fit: contain; border-radius: 12px; }
.brand-name { white-space: nowrap; }

.site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 700;
  transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

.nav-link:hover { background: var(--green-pale); color: var(--ink); transform: translateY(-1px); }
.nav-link.is-active { background: var(--green-pale); color: var(--green-dark); }
.nav-link-cta { background: var(--green); color: #173448; }
.nav-link-cta:hover { background: #6bd43b; color: #173448; }

.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 5px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.nav-greeting { max-width: 150px; overflow: hidden; color: var(--ink-soft); font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 0; }
.logout-button { border: 0; background: transparent; cursor: pointer; color: var(--green-dark); font-weight: 800; padding: 8px 9px; border-radius: 9px; }
.logout-button:hover { background: var(--coral-pale); color: var(--danger); }

.mobile-menu { display: none; }
.mobile-menu summary { list-style: none; cursor: pointer; }
.mobile-menu summary::-webkit-details-marker { display: none; }

.site-footer {
  width: min(calc(100% - 40px), var(--page-width));
  margin: 44px auto 0;
  padding: 22px 0 28px;
  border-top: 1px solid var(--line);
  color: #667d86;
  font-size: .86rem;
}

.container { width: min(calc(100% - 40px), var(--page-width)); margin: 0 auto; padding: 34px 0 54px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 0 25px; }
.page-heading h1, h1 { margin: 0; color: var(--ink); font-size: clamp(1.8rem, 4vw, 2.65rem); line-height: 1.12; letter-spacing: -.055em; }
.page-heading p { max-width: 620px; margin: 8px 0 0; color: var(--ink-soft); }
h2, h3 { color: var(--ink); letter-spacing: -.035em; line-height: 1.2; }
h2 { font-size: clamp(1.35rem, 2.5vw, 1.8rem); }

.card {
  padding: clamp(19px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--green);
  border-radius: 12px;
  background: var(--green);
  color: #173448;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
  line-height: 1.2;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.button:hover { transform: translateY(-2px); background: #6bd43b; border-color: #6bd43b; color: #173448; box-shadow: 0 7px 16px rgba(52, 127, 28, .16); }
.button:active { transform: translateY(0); }
.button-secondary { border-color: var(--line); background: #fffefa; color: var(--ink); }
.button-secondary:hover { border-color: #c4d5b8; background: var(--green-pale); color: var(--ink); }
.button-danger { border-color: #f0c4b9; background: var(--coral-pale); color: var(--danger); }
.button-danger:hover { border-color: var(--coral); background: #ffe3db; color: #8e2d29; }
.button-small { min-height: 34px; padding: 7px 12px; border-radius: 9px; font-size: .87rem; }

.field { display: flex; flex-direction: column; gap: 7px; color: var(--ink); font-weight: 700; }
.field input, .field select, .field textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="hidden"]),
select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid #cbd9c5;
  border-radius: var(--radius-small);
  background: #fffefa;
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(23, 52, 72, .025);
}
.field textarea, textarea { min-height: 118px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, input:focus, select:focus, textarea:focus { border-color: var(--green-dark); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--green-dark); }
input::placeholder, textarea::placeholder { color: #82928c; }

.alert { margin: 0 0 18px; padding: 13px 16px; border: 1px solid #cfdfc4; border-radius: 12px; background: var(--green-pale); color: #2c5e22; }
.alert-error { border-color: #f0c4b9; background: var(--coral-pale); color: #8e2d29; }
.alert-success { border-color: #c5dfb8; background: #edf8e7; color: #2d6721; }
.muted { color: #687e85; }
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--green-pale); color: var(--green-dark); font-size: .8rem; font-weight: 800; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th, .table td { padding: 13px 16px; border-bottom: 1px solid #e8eee2; vertical-align: middle; }
.table th { background: #f0f6e9; color: var(--ink); font-size: .85rem; font-weight: 800; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfdf7; }

.auth-card { width: min(100%, 470px); margin: clamp(28px, 7vh, 70px) auto; padding: clamp(24px, 5vw, 38px); border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 20px 48px rgba(23, 52, 72, .1); }
.auth-card > h1, .auth-card > h2 { margin-top: 0; }
.auth-card .brand { margin-bottom: 22px; }
.question-card { padding: clamp(18px, 3vw, 28px); border: 1px solid var(--line); border-left: 5px solid var(--green); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.option-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdf7; }
.empty-state { padding: clamp(28px, 6vw, 55px) 22px; border: 1px dashed #b8cdb0; border-radius: var(--radius); background: rgba(255, 254, 250, .72); text-align: center; }
.empty-state h2, .empty-state h3 { margin: 0 0 8px; }
.empty-state p { max-width: 520px; margin: 0 auto 18px; color: var(--ink-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .site-header-inner { width: min(calc(100% - 28px), var(--page-width)); min-height: 66px; }
  .brand-logo { width: 39px; height: 39px; }
  .site-nav { display: none; }
  .mobile-menu { display: block; position: relative; }
  .mobile-menu summary { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: .9rem; font-weight: 800; }
  .mobile-menu[open] summary { border-color: var(--green); background: var(--green-pale); }
  .mobile-menu-panel { position: absolute; top: calc(100% + 10px); right: 0; display: flex; flex-direction: column; width: min(280px, calc(100vw - 28px)); padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 16px 38px rgba(23, 52, 72, .16); }
  .mobile-menu-panel .nav-link { border-radius: 10px; }
  .mobile-menu-panel .nav-user { flex-direction: column; align-items: stretch; margin: 7px 0 0; padding: 10px 8px 2px; border-top: 1px solid var(--line); border-left: 0; }
  .mobile-menu-panel .nav-greeting { max-width: none; }
  .mobile-menu-panel .logout-button { text-align: left; }
  .container { width: min(calc(100% - 28px), var(--page-width)); padding-top: 25px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .site-footer { width: min(calc(100% - 28px), var(--page-width)); margin-top: 26px; }
  .table { min-width: 600px; }
  .room-join-form { gap: 12px; }
  .room-join-form .room-join-submit {
    align-self: center;
    width: min(100%, 300px);
    min-height: 54px;
    margin-top: 2px;
    padding: 13px 18px;
    font-size: 1rem;
    line-height: 1.25;
    white-space: normal;
  }
}

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