:root {
  --bg: #f7f4ee;
  --panel: #ffffff;
  --ink: #1d232a;
  --muted: #6b7280;
  --accent: #136f63;
  --danger: #c1121f;
  --border: #e2ded4;
  --shadow: 0 18px 45px rgba(20, 24, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Zen Kaku Gothic New", "Noto Sans JP", "BIZ UDPGothic", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(250, 246, 235, 0.95), rgba(247, 243, 233, 0.6) 45%),
    linear-gradient(180deg, #f8f5ef 0%, #efe9dd 100%);
  color: var(--ink);
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.app-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  margin-bottom: 18px;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a {
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.7);
}

.nav a.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.panel {
  background: var(--panel);
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.hidden {
  display: none;
}

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

.top-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.top-row .actions {
  margin-top: 12px;
}

.bottom-row {
  display: grid;
  grid-template-columns: 1fr;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(30, 33, 42, 0.08);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  min-width: 200px;
}

.form-row input,
.form-row textarea,
.form-row select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  background: #fcfbf8;
}

.color-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.color-row input[type="text"] {
  flex: 1 1 160px;
  min-width: 160px;
}

.color-row input[type="color"] {
  width: 56px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.color-row input[type="range"] {
  width: 120px;
  padding: 0;
}

button {
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

button:disabled {
  background: #b7b7b7;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
}

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

button.secondary {
  background: #394956;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(19, 111, 99, 0.12);
  color: var(--accent);
}

.list-item .badge.muted {
  background: rgba(107, 114, 128, 0.16);
  color: var(--muted);
}

.list-item[draggable="true"] {
  cursor: grab;
}

.list-item[draggable="true"]:active {
  cursor: grabbing;
}

.teleop-text {
  white-space: pre-wrap;
}

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

.preset-actions {
  justify-content: center;
  gap: 16px;
  padding: 16px 12px;
}

.preset-actions button {
  padding: 14px 22px;
  font-size: 16px;
  min-width: 180px;
}

.teleop-view {
  min-height: 96px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  white-space: pre-wrap;
  background: #fbfaf7;
}

.used-panel {
  padding: 0;
}

.used-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
  background: rgba(19, 111, 99, 0.08);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.used-panel .summary-hint {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

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

.used-panel > summary::after {
  content: "▼";
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.used-panel[open] > summary::after {
  transform: rotate(180deg);
}

.used-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 16px 10px;
  font-size: 13px;
  color: var(--muted);
}

.used-panel .list {
  padding: 0 16px 16px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.preset-grid .full-span {
  grid-column: 1 / -1;
}

.anim-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(19, 111, 99, 0.08);
  border: 1px dashed rgba(19, 111, 99, 0.3);
}

.anim-details h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  grid-column: 1 / -1;
}

.anim-details.hidden {
  display: none;
}

.warn {
  color: var(--danger);
  font-size: 12px;
}

.status {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: #f7f4ee;
  border-style: dashed;
}

.status-footer .status {
  margin-bottom: 0;
}

.error {
  color: var(--danger);
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(135deg, #0f766e, #0e7490);
  color: #fff;
  padding: 14px 18px 14px 48px;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 118, 110, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0;
  transform: translateX(14px) translateY(6px);
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  min-width: 220px;
  max-width: min(360px, 80vw);
  font-weight: 600;
}

.toast::before {
  content: "!";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.toast.hidden {
  display: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(0) translateY(0);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.modal:not(.hidden) {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  width: min(640px, 92vw);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.user-status {
  font-size: 14px;
  color: var(--muted);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.audit-log {
  background: #111827;
  color: #d1d5db;
  padding: 8px;
  border-radius: 8px;
  max-height: 240px;
  overflow: auto;
}

@media (max-width: 640px) {
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .app-header {
    grid-template-columns: 1fr;
  }
}
.meta-date {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.meta-id {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(107, 114, 128, 0.12);
}
