:root {
  color-scheme: light;
  --bg: #f6efe5;
  --ink: #24170f;
  --muted: #7b6959;
  --line: rgba(36, 23, 15, 0.13);
  --card: rgba(255, 252, 247, 0.92);
  --red: #9f2d20;
  --red-deep: #6d1f18;
  --gold: #d49a33;
  --green: #476b4d;
  --shadow: 0 24px 60px rgba(76, 45, 20, 0.14);
  /* Theme-switchable vars */
  --bg-glow: rgba(212, 154, 51, 0.22);
  --bg-start: #f8f0e4;
  --bg-end: #efe1cf;
  --bg-tint: #fff7eb;
  --surface: #fffaf2;
  --float-top-bg: #7a2418;
  --float-admin-bg: #8b5316;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, var(--bg-glow), transparent 34rem),
    linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell,
.floating-actions {
  display: none;
}

.is-authenticated .shell {
  display: block;
}

.is-authenticated .floating-actions {
  display: flex;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 34px;
}

.auth-card h1 {
  font-size: clamp(28px, 6vw, 40px);
  white-space: nowrap;
}

.auth-copy {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf2;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.auth-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-radius: 16px;
  background: rgba(36, 23, 15, 0.06);
  padding: 6px;
}

.auth-mode button {
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  padding: 10px 12px;
}

.auth-mode button.active {
  background: #fffaf2;
  color: var(--red-deep);
  box-shadow: 0 8px 18px rgba(76, 45, 20, 0.08);
}

.auth-status {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.user-bar {
  display: flex;
  align-items: center;
  overflow: hidden;
  min-height: 28px;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.user-bar strong {
  color: var(--red-deep);
}

.top-view-switch {
  display: inline-flex;
  gap: 6px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 242, 0.72);
  padding: 5px;
}

.top-view-button,
.private-tab,
.private-quick {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  padding: 9px 12px;
}

.top-view-button.active,
.private-tab.active {
  background: var(--surface);
  color: var(--red-deep);
  box-shadow: 0 8px 18px rgba(76, 45, 20, 0.08);
}

.app-view.hidden,
.private-tab-panel {
  display: none;
}

.private-tab-panel.active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero,
.panel {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 34px;
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "法";
  position: absolute;
  right: 390px;
  bottom: -60px;
  color: rgba(159, 45, 32, 0.07);
  font-family: Georgia, serif;
  font-size: 220px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  max-width: 760px;
  font-size: clamp(44px, 8vw, 86px);
  letter-spacing: -0.07em;
}

h2 {
  font-size: clamp(22px, 3vw, 32px);
  letter-spacing: -0.04em;
}

.hero-copy {
  max-width: 650px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.countdown-card {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 230px;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 24px;
  background: var(--red-deep);
  color: #fff9ef;
  padding: 24px;
}

.countdown-card label,
.review-form label {
  color: inherit;
  font-size: 13px;
  font-weight: 800;
}

.countdown-card input,
.review-form input,
.review-form select,
.review-form textarea,
.subject-card select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf2;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.countdown-card input {
  margin-top: 8px;
  border: 0;
}

#daysLeft {
  display: block;
  font-size: 76px;
  line-height: 0.9;
  letter-spacing: -0.08em;
}

#phaseText {
  color: rgba(255, 249, 239, 0.82);
  line-height: 1.5;
}

.grid {
  display: grid;
  gap: 24px;
  margin-bottom: 24px;
}

.top-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.middle-grid,
.bottom-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.panel {
  padding: 26px;
  width: 100%;
  min-width: 0;
}

.panel-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.generation-note {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  text-decoration: underline;
  text-decoration-color: rgba(212, 154, 51, 0.75);
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

.ai-panel {
  margin-bottom: 24px;
}

.ai-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.ai-settings label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
}

.ai-settings input {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf2;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  width: 100%;
}

.ai-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.ai-advice {
  margin-top: 16px;
}

.ai-chat {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.ai-chat-log {
  display: grid;
  max-height: 260px;
  overflow: auto;
  gap: 10px;
}

.ai-stream-section {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.ai-stream-label {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.ai-stream-output {
  width: 100%;
  min-height: 72px;
  max-height: 160px;
  overflow: auto;
  resize: none;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  outline: none;
  user-select: text;
  white-space: pre-wrap;
  word-break: break-all;
}

.ai-stream-output::placeholder {
  color: var(--muted);
}

.ai-chat-message {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fffaf2;
  width: min(78%, 720px);
  justify-self: start;
}

.ai-chat-message.is-user {
  background: rgba(109, 31, 24, 0.08);
  justify-self: end;
}

.ai-chat-message strong {
  display: block;
  margin-bottom: 4px;
  color: var(--red-deep);
  font-size: 13px;
}

.ai-chat-message p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.ai-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.ai-chat-form textarea {
  width: 100%;
  min-height: 78px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf2;
  color: var(--ink);
  padding: 12px 13px;
  line-height: 1.5;
  outline: none;
}

/* Modal Styles */
.modal {
  padding: 0;
  border: none;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 500px;
  width: 100%;
}

.modal::backdrop {
  background: rgba(36, 23, 15, 0.4);
  backdrop-filter: blur(4px);
}

.modal-content {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-content h2 {
  margin: 0;
  font-size: 24px;
}

.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  color: var(--ink);
  background: rgba(36, 23, 15, 0.07);
}

.icon-button:focus {
  outline: none;
}

.modal-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.form-group label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.form-group input,
.form-group select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf2;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.model-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.provider-settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
  padding: 16px;
  background: rgba(212, 154, 51, 0.08);
  border-radius: 16px;
  border: 1px solid var(--line);
}

.provider-settings h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.setup-steps,
.help-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.setup-steps li + li,
.help-steps li + li {
  margin-top: 8px;
}

.setup-steps code,
.setup-note code {
  display: inline-block;
  border-radius: 6px;
  background: rgba(36, 23, 15, 0.07);
  color: var(--ink);
  padding: 2px 6px;
  user-select: all;
}

.setup-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

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

.setup-note.is-loading::after {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-left: 6px;
  vertical-align: middle;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.admin-user-list {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
  margin-top: 6px;
}

.admin-user-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf2;
  padding: 10px 12px;
}

.admin-user-item strong {
  color: var(--red-deep);
}

.admin-user-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* Feedback panel */
.feedback-panel .feedback-desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.feedback-form textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: #fffaf3;
  color: var(--ink);
  line-height: 1.6;
}

.feedback-form textarea:focus {
  outline: none;
  border-color: var(--red);
}

.feedback-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.feedback-actions .setup-note {
  flex: 1;
}

/* Feedback list in admin modal */
.feedback-admin-section {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.feedback-admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.feedback-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.feedback-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 10px 12px;
}

.feedback-item.is-read {
  opacity: 0.55;
}

.feedback-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.feedback-item-meta strong {
  color: var(--red-deep);
  font-size: 13px;
}

.feedback-item-meta span {
  color: var(--muted);
  font-size: 12px;
}

.feedback-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.password-strength-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  min-height: 18px;
}

.password-strength-bar {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.25s, width 0.25s;
}

.password-strength-bar[data-level="0"] { background: var(--line); }
.password-strength-bar[data-level="1"] { background: #e74c3c; }
.password-strength-bar[data-level="2"] { background: #e67e22; }
.password-strength-bar[data-level="3"] { background: #f1c40f; }
.password-strength-bar[data-level="4"] { background: #27ae60; }

.password-strength-text {
  font-size: 11px;
  font-weight: 700;
  min-width: 24px;
  color: var(--muted);
}

.password-strength-bar[data-level="1"] ~ .password-strength-text { color: #e74c3c; }
.password-strength-bar[data-level="2"] ~ .password-strength-text { color: #e67e22; }
.password-strength-bar[data-level="3"] ~ .password-strength-text { color: #c0a000; }
.password-strength-bar[data-level="4"] ~ .password-strength-text { color: #27ae60; }

.password-match-hint {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  min-height: 16px;
}

.password-match-hint.match-ok { color: #27ae60; }
.password-match-hint.match-error { color: #e74c3c; }
.setup-note.match-ok { color: #27ae60; font-weight: 700; }
.setup-note.match-error { color: #e74c3c; font-weight: 700; }
.password-match-hint.match-error { color: #e74c3c; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.primary,
.secondary {
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  padding: 12px 18px;
}

.primary {
  background: var(--red);
  color: white;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--bg-tint);
  color: var(--red-deep);
}

.task-list {
  display: grid;
  gap: 14px;
}

.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fffaf3;
  padding: 16px;
}

.task span {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--red);
}

.task-title {
  display: block;
  font-size: 17px;
  font-weight: bold;
  line-height: 1.35;
  border: none;
  background: transparent;
  width: 100%;
  color: var(--ink);
  outline: none;
  padding: 0;
  resize: none;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.task-title:focus {
  border-bottom: 1px solid var(--red);
}

.task-detail {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  border: none;
  background: transparent;
  width: 100%;
  outline: none;
  resize: none;
  padding: 0;
}

.task-detail:focus {
  border-bottom: 1px solid var(--red);
}

.task-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.task-tag-input {
  border-radius: 999px;
  background: rgba(212, 154, 51, 0.18);
  color: #815b17;
  font-size: 12px;
  font-weight: 900;
  padding: 7px 10px;
  border: none;
  width: 80px;
  text-align: center;
  outline: none;
}

.task-tag-input:focus {
  box-shadow: 0 0 0 1px var(--gold);
}

.delete-task {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(159, 45, 32, 0.06);
  color: var(--muted);
  font-size: 13px;
  padding: 0;
  cursor: pointer;
}
.delete-task:hover {
  border-color: rgba(159, 45, 32, 0.2);
  background: rgba(159, 45, 32, 0.1);
  color: var(--red);
}

.delete-task:hover {
  text-decoration: none;
}

.task.done {
  opacity: 0.58;
}

.task.done strong {
  text-decoration: line-through;
}

.reason-box {
  margin-top: 18px;
  border-left: 4px solid var(--gold);
  background: rgba(212, 154, 51, 0.12);
  border-radius: 16px;
  padding: 16px;
}

.reason-box p,
.standard-list,
.review-item p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.reason-box p {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: baseline;
}

.reason-highlight {
  border-radius: 999px;
  background: rgba(159, 45, 32, 0.1);
  color: var(--red-deep);
  font-size: 12px;
  font-weight: 900;
  padding: 4px 9px;
}

.reason-box mark {
  border-radius: 7px;
  background: rgba(212, 154, 51, 0.24);
  color: var(--red-deep);
  font-weight: 900;
  padding: 1px 4px;
}

.reason-underline {
  text-decoration: underline;
  text-decoration-color: rgba(159, 45, 32, 0.35);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.standard-list {
  padding-left: 20px;
}

.standard-list li + li {
  margin-top: 12px;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.subject-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffaf3;
  padding: 14px;
}

.subject-card strong {
  display: block;
  margin-bottom: 10px;
}

.subject-card select {
  padding: 10px;
}

.subject-trend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.subject-progress-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffaf3;
  padding: 14px;
}

.subject-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.subject-progress-head span {
  color: var(--red-deep);
  font-weight: 900;
}

.progress-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(36, 23, 15, 0.09);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.subject-progress-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.review-stack,
.history-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.review-item,
.history-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffaf3;
  padding: 16px;
}

.history-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.history-edit-btn {
  flex-shrink: 0;
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.history-edit-btn:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.history-delete-btn {
  flex-shrink: 0;
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid rgba(159, 45, 32, 0.35);
  border-radius: 999px;
  background: rgba(159, 45, 32, 0.06);
  color: var(--red-deep);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.history-delete-btn:hover {
  background: var(--red-deep);
  color: #fff;
  border-color: var(--red-deep);
}

.review-item {
  display: grid;
  gap: 6px;
}

.review-item span,
.history-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.review-item strong {
  color: var(--green);
  font-size: 24px;
}

.review-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.review-form label {
  color: var(--muted);
}

.review-form input,
.review-form select,
.review-form textarea {
  margin-top: 8px;
}

.review-form .wide,
.review-form button {
  grid-column: 1 / -1;
}

.history-item strong {
  display: block;
  margin: 6px 0;
  font-size: 18px;
}

.history-item p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.history-meta span {
  border-radius: 999px;
  background: rgba(71, 107, 77, 0.1);
  color: var(--green);
  padding: 6px 9px;
}

.private-space-view {
  display: grid;
  gap: 18px;
}

.private-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.86);
  box-shadow: 0 18px 45px rgba(76, 45, 20, 0.1);
  padding: 26px;
}

.private-hero h1 {
  font-size: clamp(34px, 6vw, 62px);
  letter-spacing: 0;
}

.private-check-card {
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid rgba(45, 125, 90, 0.22);
  border-radius: 12px;
  background: rgba(45, 125, 90, 0.08);
  padding: 18px;
}

.private-check-card span,
.private-note,
.private-reading-meta,
.private-list-item span,
.private-trend-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.private-check-card strong {
  color: var(--green);
  font-size: 26px;
}

.private-check-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.private-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  padding: 0 0 8px;
}

.private-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.9);
  box-shadow: 0 18px 45px rgba(76, 45, 20, 0.08);
  padding: 24px;
}

.private-panel-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.private-note {
  max-width: 360px;
  line-height: 1.5;
  text-align: right;
}

.private-chat-log,
.private-list {
  display: grid;
  gap: 10px;
}

.private-chat-log {
  max-height: 360px;
  overflow: auto;
  margin-bottom: 12px;
}

.private-chat-message {
  width: min(82%, 760px);
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px 14px;
}

.private-chat-message.is-user {
  justify-self: end;
  background: rgba(45, 125, 90, 0.09);
}

.private-chat-message strong {
  display: block;
  margin-bottom: 5px;
  color: var(--red-deep);
  font-size: 13px;
}

.private-chat-message p,
.private-list-item p,
.private-reading-card p,
.private-reading-card li {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
}

.private-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.private-quick {
  border: 1px solid var(--line);
  background: var(--bg-tint);
  font-size: 13px;
}

.private-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.private-chat-form textarea,
.private-daily-form input,
.private-daily-form select,
.private-daily-form textarea,
.private-reflection-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.private-daily-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.private-daily-form label,
.private-reflection-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.private-daily-form .wide,
.private-daily-form button {
  grid-column: 1 / -1;
}

.private-reading-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(45, 125, 90, 0.2);
  border-radius: 14px;
  background: rgba(45, 125, 90, 0.07);
  padding: 18px;
}

.private-reading-card h3 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.private-reading-author {
  color: var(--green) !important;
  font-weight: 800;
}

.private-reading-card ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.private-reading-meta,
.private-reading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.private-reflection-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.private-trend,
.private-archive-grid {
  display: grid;
  gap: 12px;
}

.private-trend {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.private-trend-card,
.private-list-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px;
}

.private-trend-card strong {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: 28px;
}

.private-archive-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.private-archive-grid h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.private-list-item {
  display: grid;
  gap: 5px;
}

.private-list-item strong {
  color: var(--red-deep);
  line-height: 1.4;
}

.empty {
  color: var(--muted);
  line-height: 1.7;
}

.hidden {
  display: none !important;
}

.floating-actions {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.floating-button {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: white;
  box-shadow: 0 16px 36px rgba(109, 31, 24, 0.28);
  font-size: 24px;
  font-weight: 900;
}

.floating-button:hover {
  background: var(--red-deep);
}

.top-button {
  background: var(--red);
}

.admin-button {
  background: var(--red);
  font-size: 22px;
  position: relative;
}

.help-content {
  gap: 18px;
}

@media (max-width: 920px) {
  .hero,
  .private-hero,
  .top-grid,
  .middle-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .hero::after {
    right: 24px;
  }

  .subject-grid,
  .subject-trend,
  .private-trend,
  .private-archive-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }
}

@media (max-width: 620px) {
  .shell {
    width: calc(100% - 20px);
    max-width: 100%;
    padding-top: 10px;
    overflow-x: hidden;
  }

  /* iOS Safari 在 font-size < 16px 的 input 上会自动缩放 */
  input, select, textarea {
    font-size: 16px;
  }

  .user-bar {
    justify-content: flex-start;
    font-size: 13px;
  }

  /* 弹窗内容在手机上可滚动，不超过屏幼黄金分割高度 */
  dialog[open].modal {
    display: flex;
    flex-direction: column;
    max-height: 80svh;
    max-height: 80vh;
  }

  .modal-content {
    padding: 20px;
    overflow-y: auto;
    max-height: 61.8vh;
  }

  .hero,
  .panel {
    border-radius: 22px;
    padding: 20px;
  }

  .panel-head,
  .task {
    align-items: stretch;
  }

  .panel-head,
  .task,
  .ai-chat-form,
  .private-chat-form,
  .private-daily-form,
  .model-row,
  .review-form {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .private-panel-head {
    display: grid;
  }

  .private-note {
    max-width: none;
    text-align: left;
  }

  .private-hero,
  .private-panel {
    border-radius: 14px;
    padding: 18px;
  }

  .private-chat-message {
    width: 100%;
  }

  .subject-grid {
    grid-template-columns: 1fr;
  }

  .floating-actions {
    right: 14px;
    bottom: 14px;
  }

  #daysLeft {
    font-size: 58px;
  }
}

/* Drag and Drop styles */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel-wide {
  grid-column: auto;
}

.panel {
  position: relative;
  padding-top: 36px;
}

.panel-drag-handle {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--line);
  font-size: 20px;
  cursor: grab;
  user-select: none;
  line-height: 1;
}

.panel-drag-handle:active {
  cursor: grabbing;
}

.sortable-ghost {
  opacity: 0.4;
}

/* Update task layout for drag handle */
.task {
  position: relative;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 28px 16px 16px;
}

.task-drag-handle {
  position: absolute;
  top: 8px;
  left: 12px;
  color: var(--line);
  cursor: grab;
  font-size: 18px;
  user-select: none;
  padding: 0 4px;
  line-height: 1;
}

.task-drag-handle:active {
  cursor: grabbing;
}

.task-side {
  min-width: 92px;
}

.task-side .delete-task {
  position: absolute;
  top: 8px;
  right: 10px;
}

@media (max-width: 920px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Feedback action buttons ---- */
.feedback-item-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.feedback-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-tint);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.feedback-action-btn:hover {
  background: var(--line);
  color: var(--ink);
}

.feedback-action-btn.is-active {
  background: var(--gold);
  color: white;
  border-color: transparent;
}

.feedback-action-btn.danger:hover {
  background: var(--red);
  color: white;
  border-color: transparent;
}

/* ---- Admin badge ---- */
.feedback-badge {
  display: none;
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e74c3c;
  color: white;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}

.feedback-badge.visible {
  display: block;
}

/* ---- Theme button ---- */
.theme-button {
  background: var(--red);
  font-size: 20px;
}

/* ---- Theme panel ---- */
.theme-panel {
  position: fixed;
  right: 90px;
  bottom: 24px;
  z-index: 21;
  width: 230px;
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.theme-panel.hidden {
  display: none;
}

.theme-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.theme-panel-head strong {
  font-size: 14px;
  color: var(--ink);
}

.theme-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.theme-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.theme-swatch:hover {
  transform: scale(1.12);
}

.theme-swatch.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--bg);
}

.theme-swatch[data-theme-id="dark"] {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}

.theme-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.theme-custom-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
}

.theme-custom-label input[type="color"] {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  background: none;
}

/* ---- Dark theme overrides for hardcoded warm backgrounds ---- */
[data-theme="dark"] input:not([type="range"]):not([type="color"]):not([type="checkbox"]),
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

[data-theme="dark"] .panel,
[data-theme="dark"] .auth-card,
[data-theme="dark"] .history-item,
[data-theme="dark"] .admin-user-item,
[data-theme="dark"] .setup-steps,
[data-theme="dark"] .subject-card,
[data-theme="dark"] .review-form,
[data-theme="dark"] .ai-panel,
[data-theme="dark"] .private-hero,
[data-theme="dark"] .private-panel,
[data-theme="dark"] .private-chat-message,
[data-theme="dark"] .private-list-item,
[data-theme="dark"] .private-trend-card,
[data-theme="dark"] .private-reading-card,
[data-theme="dark"] .top-view-switch {
  background: var(--surface) !important;
  border-color: var(--line) !important;
}

[data-theme="dark"] .task {
  background: var(--surface) !important;
}

/* ---- Dev list (admin) ---- */
.devlist-admin-section {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.devlist-admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.devlist-head-actions {
  display: flex;
  gap: 6px;
}

.dev-list-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.dev-list-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.12s;
}

.dev-list-item:hover {
  background: var(--line);
}

.dev-toggle-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: color 0.12s;
}

.dev-toggle-btn:hover {
  color: var(--green);
}

.dev-list-item.is-done .dev-toggle-btn {
  color: var(--green);
}

.dev-item-text {
  flex: 1;

  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  cursor: pointer;
  word-break: break-word;
  white-space: pre-wrap;
  user-select: none;
  transition: color 0.12s;
}

.dev-item-large {
  font-size: 13px;
  font-weight: 700;
}

.dev-item-text:hover {
  color: var(--red);
  text-decoration: underline dotted;
}

.dev-list-item.is-done .dev-item-text {
  color: var(--muted);
  text-decoration: line-through;
}

.dev-item-copy-flash {
  animation: dev-copy-flash 0.4s ease;
}

@keyframes dev-copy-flash {
  0%   { background: rgba(71, 107, 77, 0.25); }
  100% { background: transparent; }
}
