:root {
  --bg: #f7faf8;
  --surface: #ffffff;
  --surface-soft: #eef5f2;
  --ink: #13201d;
  --muted: #5f6d68;
  --border: #cfdbd6;
  --brand: #004836;
  --brand-2: #0f6850;
  --accent: #c67316;
  --focus: #0c6bff;
  --danger: #9b1c1c;
  --shadow: 0 18px 45px rgba(13, 39, 31, 0.12);
  --radius: 8px;
  --font-scale: 1;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-size: calc(16px * var(--font-scale));
}

html.font-scale-small {
  --font-scale: 0.95;
}

html.font-scale-large {
  --font-scale: 1.12;
}

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(120deg, #f7faf8 0%, #eef5f2 100%);
  color: var(--ink);
  overflow-x: hidden;
}

body.theme-dark {
  --bg: #101816;
  --surface: #18231f;
  --surface-soft: #20312c;
  --ink: #edf6f2;
  --muted: #b8c7c0;
  --border: #385149;
  --brand: #cdeee2;
  --brand-2: #8fd9c1;
  --accent: #ffb65c;
  --focus: #8db8ff;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
  background: #101816;
}

body.high-contrast {
  --border: #6c7b75;
  --muted: #29332f;
}

body.high-contrast.theme-dark {
  --border: #d5e2dd;
  --muted: #edf6f2;
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  scroll-behavior: auto !important;
  transition: none !important;
  animation: none !important;
}

body.form-placeholder-body {
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
}

.form-placeholder {
  padding: 1.75rem;
}

.form-placeholder h1 {
  margin: 0 0 1rem;
  font-size: 1.45rem;
}

.form-placeholder-panel {
  max-width: 48rem;
}

.form-placeholder-panel p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
}

a {
  color: var(--brand-2);
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 10;
  transform: translateY(-160%);
  background: var(--surface);
  color: var(--ink);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.app-frame {
  display: grid;
  width: 100%;
  max-width: 100vw;
  grid-template-columns: 19.5rem minmax(0, 1fr);
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  display: flex;
  min-width: 0;
  max-width: 100%;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem 1.25rem;
  background: linear-gradient(180deg, #003f31 0%, #00513d 54%, #003629 100%);
  color: #ffffff;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  display: grid;
  width: 3.25rem;
  height: 3.25rem;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  color: #ffffff;
  font-weight: 700;
  line-height: 1;
}

.brand-title,
.brand-subtitle,
.context-label,
.session-status,
.field-note,
.form-message,
.section-heading p,
.setting-row p,
.metric-row p,
.text-panel p {
  margin: 0;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 0.2rem;
  color: rgba(255, 255, 255, 0.82);
}

.nav-list {
  display: grid;
  gap: 0.55rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: 3.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #ffffff;
  text-align: left;
  font-weight: 700;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.12);
}

.nav-icon {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  flex: 0 0 auto;
}

.nav-icon svg {
  width: 1.55rem;
  height: 1.55rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.session-panel {
  margin-top: auto;
  display: grid;
  gap: 0.8rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.session-panel h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1rem;
}

.session-status {
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.45;
}

.google-button-host {
  min-height: 2.75rem;
}

.main-panel {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  padding: 2.7rem 3rem;
}

.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.context-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--brand);
  line-height: 1.15;
  overflow-wrap: break-word;
}

h1 {
  margin: 0.2rem 0 0;
  font-size: 2.2rem;
}

h2 {
  margin: 0;
  font-size: 1.45rem;
}

h3 {
  margin: 0;
  font-size: 1.05rem;
}

.privacy-badge {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.status-banner {
  min-height: 0;
  max-width: 100%;
  margin-bottom: 1.2rem;
}

.status-banner:not(:empty) {
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.view-section {
  width: 100%;
  max-width: 74rem;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.section-heading p {
  margin-top: 0.4rem;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: break-word;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.account-layout {
  display: grid;
  grid-template-columns: minmax(17rem, 0.72fr) minmax(22rem, 1fr);
  gap: 1rem;
}

.profile-panel {
  display: flex;
  gap: 1.1rem;
  align-items: center;
  padding: 1.25rem;
}

.avatar-frame {
  display: grid;
  width: 7rem;
  height: 7rem;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--brand);
  font-size: 1.35rem;
  font-weight: 700;
}

.avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-copy {
  display: grid;
  min-width: 0;
  gap: 0.65rem;
}

.label-row,
.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.label-row {
  display: grid;
  align-items: flex-start;
  justify-content: start;
  gap: 0.45rem;
}

.label-row h3 {
  min-width: 0;
}

.field-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 1.55rem;
  padding: 0.24rem 0.48rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: left;
}

.field-badge-readonly {
  color: var(--muted);
}

.profile-copy p,
.field-note {
  color: var(--muted);
  line-height: 1.45;
}

.file-control {
  display: inline-grid;
  width: fit-content;
  gap: 0.45rem;
  color: var(--brand);
  font-weight: 700;
}

.file-control input {
  max-width: 100%;
}

.fields-panel {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field span {
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.field input:focus {
  outline: 3px solid color-mix(in srgb, var(--focus), transparent 72%);
  border-color: var(--focus);
}

.field input[readonly] {
  background: var(--surface-soft);
}

.form-message {
  min-height: 1.4rem;
  color: var(--muted);
}

.form-message.is-error {
  color: var(--danger);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding: 0.72rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: break-word;
}

.button-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.button-primary {
  background: var(--brand);
  color: #ffffff;
}

.button-primary:hover,
.button-primary:focus-visible {
  background: #006047;
}

.button-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--brand);
}

.button-muted {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.button-ghost {
  justify-content: start;
  padding-left: 0;
  background: transparent;
  color: #ffffff;
}

.session-panel .button {
  justify-self: start;
}

.metric-list,
.settings-list {
  display: grid;
}

.metric-row,
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.metric-row:last-child,
.setting-row:last-child {
  border-bottom: 0;
}

.metric-row {
  justify-content: start;
}

.metric-icon {
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--brand);
  font-size: 1.35rem;
  font-weight: 700;
}

.metric-icon svg {
  width: 1.45rem;
  height: 1.45rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.metric-icon-warm {
  color: var(--accent);
}

.metric-row p,
.setting-row p {
  color: var(--muted);
  line-height: 1.45;
}

.metric-row strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.3rem;
  color: var(--ink);
}

.segmented-control {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.segmented-control button {
  min-width: 2.5rem;
  min-height: 2.35rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.segmented-control button:nth-child(1) {
  font-size: 0.9rem;
}

.segmented-control button:nth-child(3) {
  font-size: 1.18rem;
}

.segmented-control button.is-selected {
  background: var(--brand);
  color: #ffffff;
}

.toggle-stack {
  display: grid;
  gap: 0.65rem;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 3.8rem;
  height: 2rem;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 100%;
  border-radius: 999px;
  background: #8d9894;
  transition: background 0.18s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.22rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(1.76rem);
}

.info-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.text-panel {
  padding: 1.25rem;
}

.text-panel h3 {
  margin-bottom: 0.75rem;
}

.text-panel p + p {
  margin-top: 0.75rem;
}

.text-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.text-link {
  display: inline-flex;
  margin-top: 1rem;
  font-weight: 700;
}

.form-embed-panel {
  min-height: 34rem;
  overflow: hidden;
}

.form-embed-panel iframe {
  display: block;
  width: 100%;
  min-height: 34rem;
  border: 0;
  background: var(--surface);
}

.document {
  max-width: 53.75rem;
  margin: 0 auto;
  padding: 3rem 1.25rem;
}

.document-panel {
  padding: 1.75rem;
}

.document h1 {
  margin-bottom: 1.125rem;
}

.document h2 {
  margin-top: 1.875rem;
}

.document p,
.document li {
  color: var(--muted);
  line-height: 1.65;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .app-frame {
    grid-template-columns: minmax(0, 1fr);
    overflow-x: hidden;
  }

  .sidebar {
    position: relative;
    min-width: 0;
    gap: 1rem;
    padding: 1rem;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-width: 0;
  }

  .nav-item {
    justify-content: center;
    min-height: 3rem;
  }

  .nav-item span:last-child {
    display: none;
  }

  .session-panel {
    margin-top: 0;
  }

  .main-panel {
    min-width: 0;
    padding: 1.3rem;
  }

  .account-layout,
  .info-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .section-heading,
  .setting-row,
  .metric-row {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-panel {
    align-items: start;
    flex-direction: column;
  }

  .label-row,
  .field-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.45rem;
  }

  .privacy-badge {
    width: fit-content;
  }

  .button {
    max-width: 100%;
    white-space: normal;
  }

  .section-heading > .button {
    align-self: flex-start;
  }

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