:root {
  --bg: #f6f1e8;
  --bg-2: #fffdf8;
  --ink: #1f2f2c;
  --muted: #5d6e6a;
  --line: #d5ddd8;
  --brand: #0d5c63;
  --brand-2: #e1f0ea;
  --accent: #d7a449;
  --success: #217a54;
  --danger: #af3f2d;
  --shadow: 0 18px 50px rgba(18, 50, 47, 0.12);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(215, 164, 73, 0.22), transparent 30%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  min-height: 100vh;
}

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

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell,
.layout {
  width: min(1180px, calc(100% - 32px));
}

.login-card,
.panel {
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(213, 221, 216, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card {
  max-width: 520px;
  margin: 48px auto;
  padding: 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 28px 16px 8px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar h1,
.login-card h1,
.panel h2,
.section-head h3 {
  margin: 0;
}

.eyebrow {
  color: var(--brand);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

.lead,
.muted,
.panel-head p {
  color: var(--muted);
}

.layout {
  margin: 16px auto 32px;
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 20px;
}

.panel {
  padding: 24px;
}

.panel-accent {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.panel-accent::before {
  content: "";
  position: absolute;
  inset: auto -10% 88% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(13, 92, 99, 0.08);
  pointer-events: none;
  z-index: 0;
}

.panel-head,
.section-head,
.topbar-actions,
.actions,
.result-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.panel-head {
  position: relative;
  z-index: 1;
}

.grid-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

label,
.stack-md,
.stack-lg {
  display: grid;
  gap: 8px;
}

.stack-lg {
  gap: 18px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 14px 16px;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.section-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.8);
}

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

.btn,
.chip {
  appearance: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.btn:hover,
.chip:hover {
  transform: translateY(-1px);
}

.btn {
  padding: 12px 18px;
  font-weight: 700;
}

.btn.large {
  min-width: 180px;
}

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

.btn.secondary,
.chip {
  background: var(--brand-2);
  color: var(--brand);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.success {
  background: var(--success);
  color: white;
}

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

.btn.voice {
  background: #fceccf;
  color: #8d5e15;
}

.btn.voice[data-state="recording"] {
  background: var(--danger);
  color: white;
  box-shadow: 0 0 0 4px rgba(175, 63, 45, 0.15);
}

.btn.voice[data-state="recording"]::before {
  content: "●";
  display: inline-block;
  margin-right: 6px;
  animation: pulse 1s ease-in-out infinite;
}

.btn.mini {
  padding: 8px 12px;
  font-size: 13px;
}

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.alert.error {
  background: #fde8e5;
  color: var(--danger);
}

.alert.info {
  background: #e9f6fb;
  color: #17617b;
}

.tour {
  margin-top: 24px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, #fff3d5, #fbe5bf);
}

.history-panel {
  width: min(1180px, calc(100% - 32px));
  margin: 16px auto 32px;
  overflow: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid var(--line);
  padding: 14px 12px;
  text-align: left;
  vertical-align: top;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-dialog article {
  min-width: min(720px, 90vw);
}

.history-dialog pre {
  white-space: pre-wrap;
  background: #fbfaf6;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  max-height: 60vh;
  overflow: auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  z-index: 50;
}

.toast[data-type="success"] {
  background: var(--success);
}

.toast[data-type="error"] {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.55;
    transform: scale(0.92);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

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

  .topbar,
  .panel-head,
  .section-head,
  .topbar-actions,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }
}
