﻿:root {
  color-scheme: light;
  --title: #1e40af;
  --muted: #64748b;
  --surface: rgba(255, 255, 255, 0.92);
  --border: #dbeafe;
  --bg: #f0f9ff;
  --panel-gradient: linear-gradient(180deg, #f0f9ff 0%, #d6f0fd 100%);
  --text: #1e293b;
  --label: #334155;
  --input-bg: #ffffff;
  --input-border: #dbeafe;
  --divider: #e5e7eb;
  --overlay: rgba(15, 23, 42, 0.5);
  --shadow: rgba(15, 23, 42, 0.25);
  --chart-grid: #dbeafe;
  --chart-axis: #64748b;
  --chart-value: #1e293b;
  --chart-label: #475569;
  --chart-bar-fallback: #3b82f6;
}

:root[data-theme="night"] {
  color-scheme: dark;
  --title: #93c5fd;
  --muted: #94a3b8;
  --surface: rgba(30, 41, 59, 0.96);
  --border: #334155;
  --bg: #0f172a;
  --panel-gradient: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  --text: #e2e8f0;
  --label: #cbd5e1;
  --input-bg: #1e293b;
  --input-border: #475569;
  --divider: #334155;
  --overlay: rgba(0, 0, 0, 0.65);
  --shadow: rgba(0, 0, 0, 0.5);
  --chart-grid: #334155;
  --chart-axis: #94a3b8;
  --chart-value: #f1f5f9;
  --chart-label: #cbd5e1;
  --chart-bar-fallback: #60a5fa;
}

:root[data-theme="youth"] {
  color-scheme: light;
  --title: #7c3aed;
  --muted: #7c6f8f;
  --surface: rgba(255, 255, 255, 0.94);
  --border: #e9d5ff;
  --bg: #fdf4ff;
  --panel-gradient: linear-gradient(180deg, #fdf4ff 0%, #ede9fe 50%, #dbeafe 100%);
  --text: #312e81;
  --label: #6d28d9;
  --input-bg: #ffffff;
  --input-border: #e9d5ff;
  --divider: #f3e8ff;
  --overlay: rgba(76, 29, 149, 0.35);
  --shadow: rgba(124, 58, 237, 0.25);
  --chart-grid: #ede9fe;
  --chart-axis: #7c6f8f;
  --chart-value: #7c3aed;
  --chart-label: #6d28d9;
  --chart-bar-fallback: #8b5cf6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; width: 100%; font-family: 'Noto Sans SC', sans-serif; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
.layout-container { display: flex; height: 100vh; overflow: hidden; }
.right-panel { width: 100vw; height: 100vh; position: relative; display: flex; flex-direction: column; background: var(--panel-gradient); }
.title { font-family: 'Noto Serif SC', serif; text-align: center; font-size: clamp(1.35rem, 3vw, 2rem); font-weight: bold; color: var(--title); margin: 1.5vh 0; padding: 0 1rem; }
.chart-container { margin-top: 3vh; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-x: hidden; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.chart-wrapper { min-width: 0; position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
#chart-canvas { display: block; width: 100%; }
.vote-buttons-container { position: relative; margin-top: 10px; height: 60px; width: 100%; min-width: 0; }
.vote-button { position: absolute; top: 0; transform: translateX(-50%); color: white; border: none; padding: 12px 16px; border-radius: 25px; font-size: 14px; font-weight: bold; cursor: pointer; transition: transform .2s ease, filter .2s ease; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.vote-button:hover { transform: translateX(-50%) translateY(-2px); filter: brightness(1.1); }
.vote-button:active { transform: translateX(-50%) scale(.95); }
.toolbar-button, .btn-primary, .btn-secondary { border: none; color: white; border-radius: 8px; padding: 10px 20px; font-weight: bold; cursor: pointer; transition: transform .2s ease, opacity .2s ease; }
.toolbar-button { position: fixed; top: 20px; z-index: 1000; border-radius: 25px; }
.toolbar-button:hover:not(:disabled) { transform: translateY(-2px); }
.toolbar-button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
#reset-button { right: 120px; background: linear-gradient(135deg, #ef4444, #dc2626); }
#undo-button { right: 220px; background: linear-gradient(135deg, #6b7280, #4b5563); }
#settings-button { right: 20px; background: linear-gradient(135deg, #10b981, #059669); }
.hint-container { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, .8); color: white; padding: 1rem 2rem; border-radius: 10px; z-index: 1100; opacity: 0; pointer-events: none; transition: opacity .3s ease; }
.hint-container.visible { opacity: 1; }
.settings-modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; z-index: 1200; background: var(--overlay); }
.settings-modal.open { display: flex; }
.settings-content { width: min(680px, 100%); max-height: 85vh; overflow-y: auto; padding: 24px; border-radius: 16px; background: var(--surface); box-shadow: 0 24px 60px var(--shadow); }
.settings-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-title { margin: 0; color: var(--title); font-size: 1.35rem; }
.close-button { border: 0; background: transparent; color: var(--muted); font-size: 1.8rem; cursor: pointer; }
.setting-section { margin-top: 20px; }
.setting-label { display: block; margin-bottom: 8px; font-weight: bold; color: var(--label); }
.setting-input { width: 100%; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 8px; outline: none; background: var(--input-bg); color: var(--text); }
.setting-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .15); }
.option-item { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.option-label { min-width: 38px; color: var(--muted); }
.option-input { flex: 1; min-width: 0; }
.option-color { width: 42px; height: 38px; padding: 2px; border: 1px solid var(--input-border); border-radius: 8px; background: var(--input-bg); cursor: pointer; }
.delete-option-btn { border: 0; border-radius: 8px; padding: 8px 10px; color: white; background: #ef4444; cursor: pointer; }
.delete-option-btn:disabled { opacity: .45; cursor: not-allowed; }
.add-option-section { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--divider); display: flex; justify-content: center; }
.add-option-btn { border: 0; border-radius: 8px; padding: 10px 20px; color: white; background: linear-gradient(135deg, #10b981, #059669); font-weight: bold; cursor: pointer; }
.action-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-primary { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.btn-secondary { background: linear-gradient(135deg, #6b7280, #4b5563); }
.action-buttons button:hover { transform: translateY(-2px); }
@media (max-width: 640px) {
  .toolbar-button { top: auto; bottom: 16px; padding: 10px 14px; }
  #reset-button { right: 16px; }
  #undo-button { right: 108px; }
  #settings-button { right: 196px; }
  .settings-content { padding: 16px; margin: 0; }
  .option-item { flex-wrap: wrap; }
  .option-label { width: 100%; }
  .option-input { flex-basis: calc(100% - 60px); }
  .action-buttons { flex-direction: column; }
  .action-buttons button { width: 100%; }
  .vote-button { padding: 8px 12px; font-size: 12px; border-radius: 20px; }
  .auth-screen { align-items: start; padding: 18px 14px; }
  .auth-card { margin: auto 0; padding: 26px 22px; border-radius: 18px; }
  .auth-title { font-size: 23px; }
  .auth-mark { width: 52px; height: 52px; }
  .auth-form { gap: 15px; }
}
@media (max-width: 480px) {
  .vote-button { padding: 6px 8px; font-size: 10px; min-width: 50px; }
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  color: #eafafa;
  background:
    radial-gradient(circle at 20% 10%, rgba(49, 225, 212, .16), transparent 36%),
    radial-gradient(circle at 88% 90%, rgba(0, 126, 170, .2), transparent 42%),
    #020b12;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

.auth-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .5;
}

.auth-orb-1 {
  top: -18vh;
  left: -12vw;
  width: 52vw;
  height: 52vw;
  background: radial-gradient(circle, rgba(49, 225, 212, .22), transparent 68%);
  animation: auth-float 12s ease-in-out infinite;
}

.auth-orb-2 {
  right: -16vw;
  bottom: -24vh;
  width: 58vw;
  height: 58vw;
  background: radial-gradient(circle, rgba(37, 99, 235, .24), transparent 68%);
  animation: auth-float 16s ease-in-out infinite reverse;
}

.auth-grid {
  position: absolute;
  inset: 0;
  opacity: .2;
  background-image:
    linear-gradient(rgba(82, 255, 240, .16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(82, 255, 240, .16) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at center, #000 15%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at center, #000 15%, transparent 72%);
}

@keyframes auth-float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(3vw, 2vh, 0) scale(1.06); }
}

#auth-screen.hidden,
#app-screen.hidden {
  display: none !important;
}


.auth-card {
  position: relative;
  z-index: 2;
  width: min(92vw, 440px);
  padding: 34px;
  box-sizing: border-box;
  border: 1px solid rgba(82, 255, 240, .2);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(13, 39, 47, .97), rgba(5, 19, 27, .97));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .58), inset 0 1px rgba(255, 255, 255, .05);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.auth-card::before {
  content: '';
  position: absolute;
  inset: 0 10% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, #52fff0, transparent);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.auth-brand-center {
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
  text-align: center;
}

.auth-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(82, 255, 240, .55);
  border-radius: 14px;
  color: #021013;
  background: linear-gradient(135deg, #83fff5, #31e1d4);
  box-shadow: 0 0 26px rgba(49, 225, 212, .28);
}

.auth-mark svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-brand-text {
  display: grid;
  gap: 6px;
}

.auth-kicker {
  margin: 0;
  color: #66d9d2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .24em;
}

.auth-title {
  margin: 0;
  color: #efffff;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  font-size: 27px;
  letter-spacing: .04em;
  text-align: center;
}

.auth-subtitle {
  margin: 0 0 22px;
  color: #91b5bb;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(82, 255, 240, .12);
}

.auth-tab {
  padding: 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #93c8c6;
  font-weight: bold;
  cursor: pointer;
  transition: color .16s ease, background .16s ease;
}

.auth-tab.active {
  background: rgba(49, 225, 212, .14);
  color: #7fffff;
  box-shadow: inset 0 0 0 1px rgba(82, 255, 240, .22);
}

.auth-form {
  display: flex;
  gap: 18px;
  flex-direction: column;
}

.auth-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 12px;
  outline: none;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 14px;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.auth-input::placeholder {
  color: rgba(255, 255, 255, .35);
}

.auth-input:focus {
  border-color: rgba(96, 165, 250, .6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .2);
}

.auth-input:disabled {
  opacity: .55;
}

.auth-switch {
  margin: 0;
  text-align: center;
  color: #93c8c6;
  font-size: 13px;
}

.auth-switch button {
  border: 0;
  padding: 0;
  color: #31e1d4;
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.auth-switch-link {
  color: #31e1d4;
  font-weight: 700;
  text-decoration: none;
}

.auth-switch-link:hover {
  text-decoration: underline;
}
.auth-switch button:hover:not(:disabled) {
  text-decoration: underline;
}

.auth-submit {
  width: 100%;
  min-height: 46px;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-weight: bold;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .22);
  transition: background .16s ease, transform .16s ease, opacity .16s ease;
}

.auth-submit:hover:not(:disabled) {
  background: #3b82f6;
  transform: translateY(-1px);
}

.auth-submit:disabled {
  cursor: wait;
  opacity: .65;
}

.auth-note,
.auth-footer {
  margin: 0;
  color: #93c8c6;
  font-size: 12px;
  line-height: 1.65;
}

.auth-note {
  padding: 10px 12px;
  border: 1px solid rgba(92, 226, 220, .18);
  border-radius: 10px;
  background: rgba(49, 225, 212, .08);
}

.auth-footer {
  margin-top: 18px;
  text-align: center;
}

.auth-footer a {
  color: #31e1d4;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-error {
  display: none;
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(239, 68, 68, .35);
  border-radius: 10px;
  background: rgba(239, 68, 68, .12);
  color: #fca5a5;
  font-size: 12px;
  line-height: 1.65;
}

.auth-error.visible {
  display: block;
}

.account-section {
  padding-top: 16px;
  border-top: 1px solid var(--divider);
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.account-row strong {
  color: var(--text);
}

.logout-button {
  margin-top: 10px;
  width: 100%;
  padding: 10px 16px;
  border: 1px solid #ef4444;
  border-radius: 9px;
  background: transparent;
  color: #dc2626;
  font-weight: bold;
  cursor: pointer;
}

.logout-button:hover {
  background: rgba(239, 68, 68, .08);
}

@media (max-width: 480px) {
  .auth-screen { padding: 14px; align-items: flex-start; }
  .auth-card { margin: auto; padding: 20px; border-radius: 16px; }
  .account-row { align-items: flex-start; flex-direction: column; gap: 4px; }
}

#app-screen {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
}
