:root {
  color-scheme: light;
  --ink: #17201f;
  --muted: #64706d;
  --paper: #f7f3e8;
  --panel: #fffaf0;
  --line: #d8d1c1;
  --bluebelle: #4458a6;
  --bluebelle-dark: #273674;
  --leaf: #397367;
  --amber: #b85b2f;
  --red: #a43634;
  --shadow: 0 18px 48px rgba(35, 39, 36, 0.12);
  font-family: "Aptos", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(23, 32, 31, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 32, 31, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
}

button {
  min-height: 42px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0;
  padding: 0.65rem 0.9rem;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover {
  box-shadow: 4px 4px 0 var(--ink);
  transform: translate(-2px, -2px);
}

button:active {
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(0, 0);
}

button:disabled {
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

button:focus-visible,
summary:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(68, 88, 166, 0.38);
  outline-offset: 2px;
}

button.is-processing::before,
.activity-spinner {
  animation: activity-spin 800ms linear infinite;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  display: inline-block;
  height: 0.9em;
  margin-right: 0.45rem;
  vertical-align: -0.1em;
  width: 0.9em;
}

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

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

.secondary-button {
  background: #e6efe9;
}

.warning-button {
  background: #f8d7b0;
}

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

.topbar {
  align-items: center;
  background: rgba(255, 250, 240, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.1rem clamp(1rem, 3vw, 2.2rem);
  position: sticky;
  top: 0;
  z-index: 2;
}

.kicker {
  color: var(--leaf);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 0.2rem;
  text-transform: uppercase;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.35rem;
  line-height: 1;
}

h2 {
  font-size: 1rem;
  text-transform: uppercase;
}

.hint,
.toast {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
}

.topbar-button {
  min-height: 36px;
  padding: 0.4rem 0.75rem;
}

.staff-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(320px, 1.1fr) minmax(300px, 0.9fr);
  padding: clamp(1rem, 3vw, 2.2rem);
}

.panel {
  background: rgba(255, 250, 240, 0.94);
  border: 1px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.status-panel,
.routine-panel,
.locations-panel,
.helper-panel {
  grid-column: 1 / -1;
}

.operation-indicator {
  align-items: center;
  background: #e6efe9;
  border: 1px solid var(--leaf);
  border-radius: 6px;
  display: flex;
  font-weight: 800;
  margin: 0.75rem 0 0.6rem;
  min-height: 44px;
  padding: 0.65rem 0.8rem;
}

.operation-indicator.is-idle .activity-spinner,
.operation-indicator.is-error .activity-spinner {
  display: none;
}

.operation-indicator.is-starting {
  background: #edf0fb;
  border-color: var(--bluebelle);
  color: var(--bluebelle-dark);
}

.operation-indicator.is-idle {
  background: #fffdf8;
  border-color: var(--line);
  color: var(--muted);
}

.operation-indicator.is-error {
  background: #f7d9d3;
  border-color: var(--red);
  color: var(--red);
}

.startup-progress {
  background: #e0ddd4;
  border-radius: 999px;
  height: 6px;
  margin-bottom: 0.85rem;
  overflow: hidden;
  position: relative;
}

.startup-progress[hidden] {
  display: none;
}

.startup-progress span {
  animation: startup-progress 1.6s ease-in-out infinite;
  background: var(--bluebelle);
  border-radius: inherit;
  height: 100%;
  left: -35%;
  position: absolute;
  width: 35%;
}

@keyframes startup-progress {
  to {
    left: 100%;
  }
}

.manual-panel,
.audio-panel {
  align-self: stretch;
}

.helper-panel {
  padding: 0;
}

.helper-panel summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 58px;
  padding: 0.8rem 1rem;
}

.helper-panel summary::-webkit-details-marker {
  display: none;
}

.helper-panel summary::marker {
  content: "";
}

.helper-panel summary::before {
  color: var(--bluebelle);
  content: "+";
  font-size: 1.25rem;
  font-weight: 800;
}

.helper-panel[open] summary::before {
  content: "\2212";
}

.helper-panel summary:hover .summary-title {
  color: var(--bluebelle-dark);
}

.summary-title {
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
}

.helper-content {
  border-top: 1px solid var(--line);
  padding: 1rem;
}

.helper-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.preset-list {
  display: grid;
  gap: 0.65rem;
}

.preset-item {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 0.25rem 0 0.75rem;
}

.preset-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.preset-item > div {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.preset-item span,
.preset-item code,
.preset-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.preset-item code {
  overflow-wrap: anywhere;
}

.preset-empty,
.preset-error {
  margin: 0;
}

.preset-error {
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.preset-error:empty {
  display: none;
}

.audio-controls,
.speech-control {
  display: grid;
  gap: 0.5rem;
}

.audio-controls label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.audio-field-heading {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.compact-button {
  min-height: 34px;
  padding: 0.35rem 0.65rem;
}

.sound-controls,
.voice-controls {
  align-items: end;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1fr) auto;
}

.sound-controls label,
.voice-controls label {
  grid-column: 1 / -1;
}

.audio-controls select,
.audio-controls textarea {
  background: #fffdf7;
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  padding: 0.65rem;
  resize: vertical;
  width: 100%;
}

.audio-command-row {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: 1fr 1fr;
}

.audio-error {
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 700;
  margin: 0;
  min-height: 1.1rem;
  overflow-wrap: anywhere;
}

.direction-pad {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 64px);
  justify-content: center;
  touch-action: none;
}

.manual-button {
  font-size: 1.65rem;
  min-height: 64px;
  padding: 0;
  user-select: none;
  width: 64px;
}

.manual-button.is-active {
  background: var(--leaf);
  color: white;
  transform: translate(0, 0);
}

.manual-forward {
  grid-column: 2;
  grid-row: 1;
}

.manual-left {
  grid-column: 1;
  grid-row: 2;
}

.manual-stop {
  grid-column: 2;
  grid-row: 2;
}

.manual-right {
  grid-column: 3;
  grid-row: 2;
}

.manual-reverse {
  grid-column: 2;
  grid-row: 3;
}

.event-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.toast-overlay {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
  max-width: min(420px, calc(100vw - 2rem));
  opacity: 1;
  position: fixed;
  right: 1rem;
  top: 6.5rem;
  transition: opacity 140ms ease;
  z-index: 4;
}

.toast-overlay:empty {
  opacity: 0;
  pointer-events: none;
}

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

.status-list {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  margin: 0 0 1rem;
}

.status-list div {
  border-left: 4px solid var(--bluebelle);
  background: #fffdf8;
  min-height: 62px;
  padding: 0.6rem 0.7rem;
}

dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dd {
  font-size: 1rem;
  font-weight: 800;
  margin: 0.15rem 0 0;
  overflow-wrap: anywhere;
}

.command-row,
.routine-list,
.location-grid,
.choice-list {
  display: grid;
  gap: 0.65rem;
}

.command-row {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.routine-list {
  grid-template-columns: 1fr;
}

.routine-item {
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr auto;
  padding: 0.9rem;
}

.routine-item h3,
.location-button strong {
  margin: 0;
}

.routine-item p {
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.location-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.location-button {
  align-content: center;
  display: grid;
  min-height: 64px;
  position: relative;
  text-align: left;
}

.location-button.is-processing::before {
  margin: 0;
  position: absolute;
  right: 0.7rem;
  top: 0.7rem;
}

.event-log {
  display: grid;
  gap: 0.4rem;
  list-style-position: inside;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 0;
}

.event-log li {
  background: #fffdf8;
  border-left: 4px solid var(--leaf);
  padding: 0.55rem 0.7rem;
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 1rem;
  place-items: center;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 1.4rem;
  width: 100%;
}

.login-panel h1 {
  font-size: 2.25rem;
  margin-bottom: 1.5rem;
}

.login-form,
.login-form label {
  display: grid;
  gap: 0.5rem;
}

.login-form {
  gap: 1rem;
}

.login-form label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.login-form input {
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 44px;
  padding: 0.65rem;
}

.login-error {
  color: var(--red);
  font-weight: 700;
  margin: 0;
  min-height: 1.25rem;
}

.touch-shell {
  background:
    radial-gradient(circle at 50% 15%, rgba(68, 88, 166, 0.24), transparent 28rem),
    var(--paper);
  min-height: 100vh;
  overflow: hidden;
}

.touch-stage {
  align-items: center;
  display: grid;
  gap: clamp(1rem, 4vw, 2.5rem);
  grid-template-rows: 1fr auto auto;
  min-height: 100vh;
  padding: clamp(1rem, 4vw, 2rem);
}

.ai-disclosure {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  justify-self: center;
  margin: 0;
}

.robot-face {
  align-items: center;
  aspect-ratio: 1;
  border: 10px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 24px 0 rgba(23, 32, 31, 0.12), inset 0 0 0 16px rgba(255, 255, 255, 0.36);
  display: grid;
  justify-self: center;
  max-height: min(62vh, 680px);
  max-width: min(78vw, 680px);
  overflow: hidden;
  place-items: center;
  position: relative;
  width: 100%;
}

.robot-face::before {
  border: 2px dashed rgba(23, 32, 31, 0.22);
  border-radius: 50%;
  content: "";
  inset: 7%;
  position: absolute;
}

.mood-calm {
  background: linear-gradient(145deg, #e8efe8, #fdf7df);
}

.mood-attentive {
  background: linear-gradient(145deg, #cad7ff, #fff2c8);
}

.mood-active {
  background: linear-gradient(145deg, #f8c96c, #8fced1);
}

.mood-focused {
  background: linear-gradient(145deg, #a6d6bd, #d9ddff);
}

.mood-settled {
  background: linear-gradient(145deg, #dfebd8, #c6d1e9);
}

.face-core {
  display: grid;
  gap: clamp(1rem, 4vw, 2rem);
  place-items: center;
}

.eye-row {
  display: flex;
  gap: clamp(1.8rem, 8vw, 5rem);
}

.eye {
  background: var(--ink);
  border-radius: 50%;
  display: block;
  height: clamp(42px, 9vw, 92px);
  width: clamp(42px, 9vw, 92px);
}

.mouth {
  border: 10px solid var(--ink);
  border-left: 0;
  border-top: 0;
  border-radius: 0 0 120px 0;
  height: clamp(34px, 7vw, 72px);
  transform: rotate(45deg);
  width: clamp(34px, 7vw, 72px);
}

.face-message {
  bottom: 12%;
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 800;
  left: 14%;
  margin: 0;
  max-width: 72%;
  overflow-wrap: anywhere;
  position: absolute;
  text-align: center;
}

.touch-controls {
  justify-self: center;
  max-width: 760px;
  width: min(100%, 760px);
}

.touch-controls h1 {
  font-size: clamp(1.7rem, 5vw, 3rem);
  margin-bottom: 0.8rem;
  text-align: center;
}

.choice-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.choice-list button {
  background: var(--bluebelle);
  color: white;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  min-height: 76px;
}

@media (max-width: 900px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .staff-grid,
  .command-row {
    grid-template-columns: 1fr;
  }

  .routine-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 0.8rem;
    position: static;
  }

  h1 {
    font-size: 1.9rem;
  }

  .topbar-button {
    width: 100%;
  }

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

  .status-list div {
    min-width: 0;
  }

  .toast-overlay {
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    top: auto;
  }

  .sound-controls,
  .voice-controls,
  .audio-command-row,
  .preset-item {
    grid-template-columns: 1fr;
  }

  .preset-item button {
    width: 100%;
  }
}
