:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-border: #d9dce1;
  --color-text: #1f2430;
  --color-text-muted: #5c6270;
  --color-primary: #1f9488;
  --color-primary-dark: #157468;
  --color-danger: #d64545;
  --color-danger-bg: #fdeaea;
  --color-success: #1c8a4b;
  --color-success-bg: #e8f7ee;
  --radius: 8px;
  --max-width: 620px;

  /* Brand palette, pulled from the Visionarium logo */
  --brand-navy: #161b45;
  --brand-navy-2: #1d3566;
  --brand-teal: #1f9488;
  --brand-gold: #c98a3e;
  --brand-gradient: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-teal) 100%);

  --shadow-sm: 0 1px 3px rgba(20, 24, 40, .08);
  --shadow-md: 0 6px 18px rgba(20, 24, 40, .12);
}

* { box-sizing: border-box; }

html {
  font-size: 15px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* Guarantee the [hidden] attribute always wins over any component's own
   `display` rule (inline-flex/flex buttons, panels, etc.) — without this,
   an element styled with e.g. `display:flex` stays visible even when
   marked hidden, since author CSS otherwise overrides the UA default. */
[hidden] {
  display: none !important;
}

img, video, audio { max-width: 100%; }

.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;
}

.page {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: .85rem .75rem 2rem;
}

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gradient);
  opacity: 1;
  visibility: visible;
  transition: opacity .4s ease, visibility .4s ease;
}
.page-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.page-loader-logo {
  width: 130px;
  height: auto;
  animation: page-loader-pulse 1.3s ease-in-out infinite;
}
@keyframes page-loader-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: .7; }
}

.page-header { text-align: center; margin-bottom: .85rem; }
.page-header .logo {
  display: block;
  width: 100%;
  max-width: 140px;
  height: auto;
  margin: 0 auto .5rem;
}
.page-header h1 { font-size: 1.15rem; margin: 0 0 .2rem; }
.subtitle { color: var(--color-text-muted); margin: 0; font-size: .82rem; }

.field-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .7rem .75rem .85rem;
  margin: 0 0 .85rem;
}

.field-group legend {
  font-weight: 600;
  padding: 0 .3rem;
  font-size: .88rem;
}

.legend-with-info {
  display: flex;
  align-items: center;
  gap: .3rem;
}

.field { margin-top: .65rem; }
.field:first-child { margin-top: .2rem; }

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
}
.field-row .field { flex: 1 1 200px; margin-top: .65rem; }

label, legend {
  display: block;
  font-weight: 600;
  font-size: .8rem;
  margin-bottom: .2rem;
  user-select: none;
  -webkit-user-select: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-weight: 400;
  font-size: .74rem;
  margin-top: .3rem;
  color: var(--color-text-muted);
}
.checkbox-label input { width: .9rem; height: .9rem; }

.required { color: var(--color-danger); }

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: .85rem;
  padding: .45rem .55rem;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: var(--color-surface);
  color: var(--color-text);
  min-height: 38px;
}

textarea { resize: vertical; min-height: 2.75rem; }

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.info-btn {
  border: none;
  background: none;
  color: var(--color-primary);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: .1rem .2rem;
  min-width: 32px;
  min-height: 32px;
}

button {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  padding: .45rem .75rem;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 38px;
}

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: filter .15s ease, transform .15s ease;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; filter: none; transform: none; }

.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn-secondary:hover { background: #eef0f3; }

.btn-record {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: #f3c9c9;
}

.btn-block { width: 100%; font-size: .9rem; }

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}

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

.submit-hint {
  text-align: center;
  font-size: .78rem;
  color: var(--color-text-muted);
  margin: .5rem 0 0;
}

.ideas-container {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .4rem;
}

.idea-row {
  border: 1px solid var(--color-border);
  border-radius: 7px;
  padding: .55rem;
  background: #fbfbfc;
}

.idea-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .4rem;
}

.idea-number {
  font-size: .78rem;
  font-weight: 700;
  color: var(--brand-teal);
}

.idea-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  overflow: hidden;
}

.mode-btn {
  border: none;
  background: var(--color-surface);
  color: var(--color-text-muted);
  padding: .3rem .6rem;
  font: inherit;
  font-size: .76rem;
  cursor: pointer;
  min-height: 32px;
}
.mode-btn.active { background: var(--color-primary); color: #fff; }

.remove-idea-btn {
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  min-width: 32px;
  min-height: 32px;
}
.remove-idea-btn:hover { color: var(--color-danger); }

.idea-text-input { width: 100%; }

.voice-controls {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.record-timer {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  font-size: .78rem;
}

.voice-error {
  color: var(--color-danger);
  font-size: .74rem;
  margin-top: .35rem;
}

.voice-preview {
  margin-top: .45rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.voice-preview audio { width: 100%; height: 34px; }

.form-alert {
  border-radius: 7px;
  padding: .5rem .7rem;
  margin-bottom: .75rem;
  font-size: .82rem;
}
.form-alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.form-alert-success { background: var(--color-success-bg); color: var(--color-success); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 25, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  padding: .75rem .9rem .9rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.modal-header h2 { font-size: .95rem; margin: 0; }

.modal-close {
  border: none;
  background: none;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
  min-width: 32px;
  min-height: 32px;
}

.modal-body { margin-top: .35rem; font-size: .82rem; color: var(--color-text); }

/* Admin */
.admin-page {
  background: linear-gradient(180deg, #eef2f8 0%, #f4f5f7 220px);
}
.admin-page .page { max-width: 840px; }

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: .55rem .8rem;
  margin-bottom: .75rem;
  border-top: 3px solid transparent;
  border-image: var(--brand-gradient) 1;
}

.admin-logo {
  width: 54px;
  height: auto;
}

.admin-user {
  font-size: .76rem;
  color: var(--color-text-muted);
}

.admin-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--brand-gradient);
}

.admin-login-card {
  width: 100%;
  max-width: 330px;
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 1.35rem 1.25rem;
  text-align: center;
}

.login-logo {
  width: 88px;
  height: auto;
  margin: 0 auto .5rem;
  display: block;
}

.admin-login-card h1 {
  font-size: 1.05rem;
  margin: 0 0 .2rem;
  color: var(--brand-navy);
}

.admin-login-card .subtitle {
  margin-bottom: .9rem;
}

.admin-login-card form {
  text-align: left;
}

.submission-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: .6rem;
}

.submission-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--brand-teal);
  border-radius: var(--radius);
  padding: .7rem .8rem .8rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, transform .15s ease;
}
.submission-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.submission-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .4rem .7rem;
  margin-bottom: .4rem;
}
.submission-card-header strong { font-size: .92rem; }
.submission-date { color: var(--color-text-muted); font-size: .7rem; margin-left: auto; }

.delete-form { display: inline-flex; margin: 0; }

.delete-btn {
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  transition: background .15s ease, color .15s ease;
}
.delete-btn:hover { background: var(--color-danger-bg); color: var(--color-danger); }

.zone-badge {
  display: inline-block;
  background: var(--brand-gradient);
  color: #fff;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: .18rem .55rem;
  border-radius: 999px;
}

.submission-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .4rem;
  margin-bottom: .5rem;
}
.submission-meta span {
  background: var(--color-bg);
  border-radius: 999px;
  padding: .15rem .5rem;
  font-size: .74rem;
  color: var(--color-text-muted);
}

.submission-bio {
  font-size: .84rem;
  margin-bottom: .6rem;
  color: var(--color-text);
}

.submission-ideas {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.idea-item {
  border: 1px solid var(--color-border);
  border-radius: 7px;
  padding: .45rem .6rem;
  font-size: .82rem;
  background: #fbfbfc;
}

.idea-item-tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: .25rem;
}
.idea-item-voice .idea-item-tag { color: var(--brand-teal); }
.idea-item-text .idea-item-tag { color: var(--brand-gold); }

.idea-item audio { width: 100%; height: 34px; margin-top: .3rem; }
.idea-item .idea-download { font-size: .74rem; margin-left: .5rem; }

.filter-bar {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: .5rem .7rem;
  margin-bottom: .75rem;
}
.filter-bar select { min-width: 150px; width: auto; }

.submission-count-badge {
  margin-left: auto;
  background: var(--color-bg);
  border-radius: 999px;
  padding: .2rem .6rem;
  font-size: .74rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  background: var(--color-surface);
}

@media (min-width: 640px) {
  .page { padding-top: 1.25rem; }
  .page-header h1 { font-size: 1.4rem; }
}
