:root {
  color-scheme: light;
  --bg: #fff8ed;
  --ink: #1e2430;
  --muted: #657084;
  --line: #ded6f0;
  --panel: #fffdf8;
  --panel-strong: #fff0b8;
  --accent: #00a6a6;
  --accent-dark: #007a7a;
  --accent-soft: #d9fbf7;
  --warm: #ff6b6b;
  --sun: #ffd166;
  --violet: #7c5cff;
  --sky: #4dabf7;
  --shadow: 0 18px 50px rgba(30, 36, 48, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 209, 102, 0.36), transparent 26%),
    radial-gradient(circle at 88% 12%, rgba(124, 92, 255, 0.22), transparent 26%),
    radial-gradient(circle at 18% 88%, rgba(0, 166, 166, 0.24), transparent 28%),
    linear-gradient(135deg, #fff8ed 0%, #f4fbff 46%, #fff1f1 100%);
  color: var(--ink);
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: stretch;
  min-height: 300px;
  margin-bottom: 24px;
}

.hero-copy,
.result-panel,
.control-panel,
.custom-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.hero-copy {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 5vw, 56px);
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.78), rgba(255, 253, 248, 0.88) 42%, rgba(217, 251, 247, 0.92)),
    url("https://images.unsplash.com/photo-1498837167922-ddd27525d352?auto=format&fit=crop&w=1400&q=80") center/cover;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 680px;
  margin-bottom: 18px;
  font-size: clamp(2.25rem, 6vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lead {
  max-width: 540px;
  margin-bottom: 0;
  color: #4b5568;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.result-panel {
  display: flex;
  min-height: 300px;
  padding: 28px;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(135deg, #243b6b, #7c5cff 54%, #ff6b6b);
  color: #fffdf8;
}

.result-label {
  width: fit-content;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 253, 248, 0.22);
  border-radius: 999px;
  padding: 7px 12px;
  color: #fff0b8;
  font-size: 0.82rem;
  font-weight: 800;
}

#resultText {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

#resultReason {
  margin: 18px 0 0;
  color: rgba(255, 253, 248, 0.72);
  line-height: 1.6;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr) minmax(260px, 0.7fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.custom-panel,
.history-panel {
  padding: 20px;
}

.section-heading {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.category-button {
  display: grid;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.category-button[aria-checked="true"] {
  border-color: var(--violet);
  background: linear-gradient(135deg, var(--accent-soft), #fff4d1);
  box-shadow: inset 0 0 0 1px var(--violet);
}

.category-icon {
  display: grid;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  place-items: center;
  background: linear-gradient(135deg, var(--sun), #ffd6a5);
  color: #543c00;
  font-weight: 900;
}

.category-title {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.category-desc {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  min-height: 188px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

.toggle-row {
  margin: 14px 0 18px;
}

.toggle-row label {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #4b5568;
  font-size: 0.92rem;
  font-weight: 700;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--violet);
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 50px;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--sky));
  color: #fffdf8;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: linear-gradient(135deg, var(--accent-dark), var(--violet));
}

.secondary-button {
  background: linear-gradient(135deg, var(--warm), var(--violet));
  color: #fffdf8;
}

.text-button,
.icon-button {
  min-height: 36px;
  background: #fff0b8;
  color: var(--ink);
}

.text-button {
  padding: 0 12px;
}

.icon-button {
  width: 36px;
  font-size: 1.2rem;
}

.history-list {
  display: grid;
  max-height: 390px;
  margin: 0;
  padding: 0;
  gap: 10px;
  overflow: auto;
  list-style: none;
}

.history-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.history-item-title {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.history-item-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

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

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

  .result-panel {
    min-height: 230px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0 20px;
  }

  .hero {
    gap: 10px;
    margin-bottom: 10px;
  }

  .tool-grid {
    gap: 10px;
  }

  .hero-copy,
  .result-panel,
  .control-panel,
  .custom-panel,
  .history-panel {
    padding: 16px;
  }

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

  h1 {
    font-size: 2.35rem;
  }
}

.person-box {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.person-field {
  margin-bottom: 8px;
}

input[type="text"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

input[type="text"]:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(124, 92, 255, 0.24);
  outline-offset: 2px;
}

.person-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

[hidden] {
  display: none !important;
}

.welcome-screen {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: center;
}

.welcome-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(24px, 6vw, 48px);
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.84), rgba(255, 253, 248, 0.9) 36%, rgba(0, 166, 166, 0.18) 68%, rgba(124, 92, 255, 0.2)),
    url("https://images.unsplash.com/photo-1498837167922-ddd27525d352?auto=format&fit=crop&w=1000&q=80") center/cover;
  box-shadow: var(--shadow);
}

.nickname-form {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.welcome-note {
  color: #6d4aff;
  font-size: clamp(0.92rem, 1.7vw, 1.05rem);
  line-height: 1.55;
}

.active-person-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.active-person-row strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.15rem;
}

.person-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

@media (max-width: 560px) {
  .welcome-screen {
    min-height: calc(100vh - 20px);
  }

  .welcome-card {
    min-height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

input[type="password"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

input[type="password"]:focus {
  outline: 3px solid rgba(124, 92, 255, 0.24);
  outline-offset: 2px;
}

.auth-message {
  margin: 0;
  color: #111827;
  font-size: 0.86rem;
  line-height: 1.45;
}

.auth-message[data-tone="error"] {
  color: #c92a2a;
  font-weight: 800;
}

.auth-message[data-tone="success"] {
  color: var(--accent-dark);
  font-weight: 800;
}
