:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --surface: #fffdf8;
  --line: #d8d2c8;
  --ink: #25231f;
  --muted: #746f67;
  --accent: #256d72;
  --accent-2: #9b4d35;
  --soft: #e8f0ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}

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

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

.auth-gate[hidden],
.app[hidden] {
  display: none;
}

.auth-card {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-card p {
  color: var(--muted);
  line-height: 1.5;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.auth-card input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.auth-card textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

.auth-register {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.auth-register summary {
  cursor: pointer;
  color: var(--accent);
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 960px);
  justify-content: center;
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

body.parent-mode .app {
  grid-template-columns: minmax(0, 1fr) 360px;
  justify-content: stretch;
}

.chat,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 32px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

#status {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.messages {
  overflow: auto;
  padding: 16px;
}

.voice-panel {
  display: grid;
  grid-template-columns: 120px 140px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fbf8f1;
}

.voice-panel button {
  height: 38px;
}

#voice-hold {
  background: var(--accent-2);
}

#voice-hold:active {
  filter: brightness(0.9);
}

#voice-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.msg {
  max-width: 760px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.msg.user {
  margin-left: auto;
  background: var(--soft);
}

.msg.bot {
  background: #f1ede5;
}

.msg-meta {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

body.parent-mode .msg-meta {
  display: flex;
}

.msg-meta small {
  overflow-wrap: anywhere;
}

.scene-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid #bfd2d0;
  border-radius: 999px;
  background: #eef6f4;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.35;
}

.script-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid #dbc9bd;
  border-radius: 999px;
  background: #fff7f2;
  color: var(--accent-2);
  font-size: 12px;
  line-height: 1.35;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

input {
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

select {
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

button {
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: #1f5c60;
}

.side {
  display: none;
  grid-template-rows: auto auto minmax(220px, 1fr) minmax(160px, 240px);
  gap: 16px;
  min-height: calc(100vh - 32px);
}

body.parent-mode .side {
  display: grid;
}

.parent-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  align-items: center;
  gap: 10px;
}

.parent-tools h2 {
  margin-bottom: 4px;
}

.parent-tools button {
  height: 38px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.parent-actions {
  margin-bottom: 10px;
}

.parent-dashboard {
  margin-bottom: 12px;
}

.auth-registrations {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.registration-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.dashboard-grid article {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
}

.dashboard-grid article.warn {
  border-left-color: var(--accent-2);
}

.dashboard-grid strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.dashboard-grid span,
.dashboard-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.dashboard-note {
  margin-top: 8px;
}

.first-run-taskboard {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.taskboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.taskboard-head span {
  color: var(--muted);
  font-size: 12px;
}

.taskboard-list {
  display: grid;
  gap: 8px;
}

.taskboard-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
  background: #fff;
}

.taskboard-list article.done {
  border-left-color: var(--accent);
}

.taskboard-list article.waiting {
  border-left-color: #6b6258;
  background: #fbf8f1;
}

.taskboard-list strong,
.taskboard-list span {
  display: block;
  overflow-wrap: anywhere;
}

.taskboard-list strong {
  font-size: 13px;
  line-height: 1.35;
}

.taskboard-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.taskboard-list button {
  min-width: 0;
  height: 34px;
  padding: 0 6px;
  font-size: 12px;
  line-height: 1.2;
}

.taskboard-list button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.parent-actions button,
.manual-record button,
.parent-control-form button,
.model-control-form button {
  width: 100%;
}

.parent-control-form,
.model-control-form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.parent-control-form label,
.model-control-form label {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.parent-control-form > label,
.model-control-form > label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-grid input {
  width: 100%;
  height: 34px;
}

.control-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.model-readiness {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  line-height: 1.35;
}

.model-readiness li {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow-wrap: anywhere;
}

.model-readiness .passed {
  border-left: 4px solid var(--accent);
}

.model-readiness .blocked {
  border-left: 4px solid var(--accent-2);
}

.model-readiness .waiting {
  color: var(--muted);
}

.model-rehearsal {
  display: grid;
  gap: 8px;
}

.rehearsal-summary {
  padding: 9px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
}

.rehearsal-summary strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

.rehearsal-summary span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.rehearsal-list {
  display: grid;
  gap: 8px;
}

.rehearsal-list article {
  padding: 9px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
}

.rehearsal-list article.needs_review {
  border-left-color: var(--accent-2);
}

.rehearsal-list article.blocked {
  border-left-color: #6b6258;
}

.rehearsal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.rehearsal-head span,
.rehearsal-list small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.rehearsal-list p {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.rehearsal-list small {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.feedback-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.feedback-actions button {
  min-width: 0;
  height: 30px;
  padding: 0 4px;
  background: #6b6258;
  font-size: 12px;
  line-height: 1.2;
}

.feedback-actions button[data-feedback="approved"] {
  background: var(--accent);
}

.feedback-actions button[data-feedback="boundary_risk"] {
  background: var(--accent-2);
}

.model-optimization {
  display: grid;
  gap: 8px;
}

.optimization-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.optimization-head span {
  color: var(--muted);
  font-size: 12px;
}

.optimization-list {
  display: grid;
  gap: 8px;
}

.optimization-list article {
  padding: 9px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
  background: #fff;
}

.optimization-list article.active {
  border-left-color: var(--accent);
}

.optimization-list article.history {
  border-left-color: #6b6258;
  background: #fbf8f1;
}

.optimization-list p,
.optimization-list small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.optimization-list button {
  width: 100%;
  height: 32px;
  margin-top: 8px;
}

.family-guide {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.family-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.family-guide-head span {
  color: var(--muted);
  font-size: 12px;
}

.family-guide-list {
  display: grid;
  gap: 8px;
}

.family-guide-list button {
  height: auto;
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.family-guide-list button:hover {
  background: #eef6f4;
}

.family-guide-list strong,
.family-guide-list span {
  display: block;
  overflow-wrap: anywhere;
}

.family-guide-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.manual-record {
  display: grid;
  gap: 8px;
}

.manual-record input {
  height: 38px;
}

.manual-record textarea {
  min-height: 50px;
  margin-top: 0;
}

.summary {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.summary dd {
  white-space: pre-wrap;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.project-tracks {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.project-track {
  padding: 9px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
}

.project-track.ready_disabled,
.project-track.prototype {
  border-left-color: var(--accent-2);
}

.track-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.track-head span {
  color: var(--muted);
  font-size: 12px;
}

.project-track p,
.project-track small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

dl {
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

dd {
  margin: 4px 0 0;
  line-height: 1.55;
}

.pending-panel,
.beautiful-panel,
.reviewed-panel {
  overflow: hidden;
}

.pending,
.beautiful-moments,
.reviewed {
  display: grid;
  gap: 10px;
  max-height: 100%;
  overflow: auto;
}

.pending-item,
.beautiful-item,
.reviewed-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.pending-item time,
.beautiful-item time,
.reviewed-item time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.pending-message,
.reviewed-item div {
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.pending-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.beautiful-item {
  border-left-color: var(--accent);
}

.beautiful-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.pending-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.pending-tags span:not(.scene-pill) {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbf8f1;
}

.pending-suggestion {
  margin-top: 8px;
  padding: 8px;
  border-radius: 6px;
  background: #f7f4ef;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.pending-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.pending-review-question {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #d9c4b8;
  border-radius: 6px;
  background: #fff7f2;
  color: var(--accent-2);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.pending-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.pending-actions button {
  height: 36px;
}

.pending-actions button[data-action="reject"] {
  background: #6b6258;
}

.reviewed-item {
  border-left-color: var(--accent);
}

.reviewed-item.rejected {
  border-left-color: #6b6258;
}

.reviewed-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  body.parent-mode .app {
    grid-template-columns: 1fr;
  }

  .chat,
  .side {
    min-height: auto;
  }

  .side {
    grid-template-rows: auto auto;
  }

  .voice-panel {
    grid-template-columns: 1fr 1fr;
  }

  #voice-status {
    grid-column: 1 / -1;
  }
}

/* Parent console V1.1: prioritize review work over configuration. */
body.parent-mode .app {
  grid-template-columns: minmax(380px, 1fr) minmax(520px, 680px);
}

.parent-console {
  grid-template-rows: none;
  align-content: start;
  gap: 12px;
  overflow: auto;
  max-height: calc(100vh - 32px);
  padding-right: 2px;
}

.parent-tools {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 6px 16px rgba(37, 35, 31, 0.08);
}

.parent-tools h2 {
  font-size: 20px;
}

.console-priority,
.console-review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.console-review-grid .panel {
  min-height: 260px;
}

.section-head,
.admin-section summary,
.project-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-head span,
.admin-section summary,
.project-panel summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.admin-section summary,
.project-panel summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.admin-section[open] summary,
.project-panel[open] summary {
  margin-bottom: 12px;
}

.auth-card-panel[hidden] {
  display: none;
}

.auth-card-panel {
  border-top: 4px solid #4b6f44;
}

.pending-panel {
  border-top: 4px solid var(--accent-2);
}

.beautiful-panel {
  border-top: 4px solid #5c6f9b;
}

.parent-dashboard-card,
.safety-panel {
  border-top: 4px solid var(--accent);
}

.parent-panel {
  border-top: 4px solid #6b6258;
}

.dashboard-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-grid article {
  min-height: 74px;
}

.dashboard-grid strong {
  font-size: 20px;
}

.parent-control-form,
.model-control-form,
.manual-record {
  margin-top: 10px;
}

.parent-actions {
  margin: 12px 0 0;
}

.reviewed-panel {
  max-height: 260px;
  overflow: auto;
}

@media (max-width: 1200px) {
  body.parent-mode .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .parent-console {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .console-priority,
  .console-review-grid,
  .dashboard-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .parent-tools,
  .section-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .voice-panel,
  .composer {
    grid-template-columns: 1fr;
  }
}
