*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --surface: #ffffff;
  --text: #1a1a2e;
  --muted: #5c5c6f;
  --accent: #3d5a80;
  --accent-soft: #e8eef5;
  --border: #ddd6c8;
  --shadow: 0 10px 30px rgba(26, 26, 46, 0.08);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12121a;
    --surface: #1c1c28;
    --text: #f2f0ea;
    --muted: #a8a8b8;
    --accent: #8cb4d9;
    --accent-soft: #243044;
    --border: #2f2f3d;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top, rgba(61, 90, 128, 0.12), transparent 42%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 1.5rem 1.25rem calc(1.5rem + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.header {
  padding-top: 0.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.word {
  margin: 0;
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  line-height: 1.15;
  font-weight: 700;
  word-break: break-word;
}

.definition-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.1rem;
}

.definition {
  margin: 0;
  font-size: 1.05rem;
}

.details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.detail-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 600 0.95rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: left;
  cursor: pointer;
}

.detail-toggle:hover,
.detail-toggle:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.chevron {
  flex-shrink: 0;
  width: 0.75rem;
  height: 0.75rem;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-top: -0.2rem;
}

.detail-item[open] .chevron {
  transform: rotate(225deg);
  margin-top: 0.2rem;
}

.detail-panel {
  padding: 0 1rem 1rem;
  color: var(--muted);
  font-size: 0.98rem;
}

.detail-panel p {
  margin: 0;
}

.search {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.search-label {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 12pt;
  font-weight: 700;
  line-height: 1.2;
  color: var(--muted);
}

.search-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #e8f5e9;
  color: var(--text);
  font: 1rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: var(--shadow);
}

.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 14rem;
  overflow-y: auto;
}

.search-result-btn {
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 500 0.95rem/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
}

.search-result-btn:hover,
.search-result-btn:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.search-empty {
  padding: 0.65rem 0.2rem;
  font: 500 0.9rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--muted);
}

.actions {
  margin-top: auto;
  display: grid;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 1.25rem;
  font: 600 1rem/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 480px) {
  .app {
    padding-top: 2.5rem;
  }
}
