:root {
  --bg: #f5f2ee;
  --card: #ffffff;
  --text: #1f1d1a;
  --muted: #847f78;
  --accent: #b5793b;
  --border: #e7e2da;
  --terracotta: #C4714A;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --card: #242322;
  --text: #f5f2ee;
  --muted: #9a958d;
  --border: #3a3733;
}

body {
  transition: background 0.3s ease, color 0.3s ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
}

.layout {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  gap: 48px;
  will-change: transform, opacity;
  transform-origin: center top;
}

.col-image {
  flex: 0 0 45%;
  max-width: 45%;
  height: 100vh;
}

.col-text {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 64px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.content-middle {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.content-middle > * {
  margin: 0;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #999;
  font-weight: 500;
}

.masthead {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.masthead-word {
  font-weight: 800;
  color: #C4714A;
  margin-right: 0.4em;
}

.masthead-rest {
  font-weight: 400;
  color: #1a1a1a;
}

.masthead-line {
  flex: 1;
  height: 1px;
  background: #e0e0e0;
}

.accent-bar {
  width: 40px;
  height: 3px;
  background: #c4714a;
}

.word-image {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.word-image.loaded {
  display: inline-block;
}

#word {
  font-family: 'Fraunces', serif;
  font-size: clamp(4.5rem, 9vw, 5rem);
  font-weight: 600;
  text-transform: lowercase;
  line-height: 1.05;
  color: #1a1a1a;
}

.ipa {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 300;
  font-size: 15px;
  color: #aaa;
  letter-spacing: 0.02em;
}

.pos {
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
}

.definition {
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.7;
}

.divider {
  border: none;
  border-top: 1px solid #eee;
}

.etymology {
  border-left: 2px solid #C4714A;
  padding: 0 0 0 16px;
  text-align: left;
}

.etymology-label {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.etymology-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.example {
  font-size: 16px;
  line-height: 1.6;
  color: var(--muted);
  font-style: italic;
}

.example::before, .example::after {
  content: '"';
}

.source {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

.date {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.error {
  color: #c4554d;
}

.in-the-wild {
  min-height: 100vh;
  width: 100%;
  padding: 96px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.section-label {
  margin: 0 0 48px;
  text-align: center;
}

.wild-cards {
  display: flex;
  gap: 32px;
  max-width: 1200px;
  width: 100%;
}

.wild-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.wild-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.wild-pub {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.wild-excerpt {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  font-style: italic;
  color: var(--text);
  flex: 1;
}

.wild-excerpt em {
  font-style: italic;
  font-weight: 600;
}

.wild-source {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.auth-wrap {
  position: relative;
  margin-left: 12px;
  flex: 0 0 auto;
}

.user-btn {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  padding: 0;
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease;
}

.user-btn:hover {
  background: var(--border);
}

.user-btn svg {
  width: 17px;
  height: 17px;
}

.auth-dot {
  position: absolute;
  bottom: 1px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--terracotta);
  border: 1.5px solid var(--bg);
}

.auth-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  min-width: 110px;
  overflow: hidden;
  z-index: 50;
}

.auth-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.auth-dropdown-item:hover {
  background: var(--bg);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-modal {
  position: relative;
  width: 320px;
  max-width: 90vw;
  background: var(--card);
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  font-family: 'Inter', system-ui, sans-serif;
}

.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
}

.auth-title {
  margin: 0 0 24px;
  font-family: 'Fraunces', serif;
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.auth-input {
  display: block;
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.auth-input:focus {
  outline: none;
  border-color: var(--terracotta);
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  border: none;
  border-radius: 6px;
  background: var(--terracotta);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.auth-submit:hover {
  opacity: 0.92;
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.auth-error {
  margin: 0 0 12px;
  font-size: 12px;
  color: #c4554d;
  text-align: center;
}

.auth-toggle {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.auth-toggle a {
  color: var(--terracotta);
  font-weight: 600;
  text-decoration: none;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

@media (max-width: 820px) {
  .layout { height: auto; flex-direction: column; padding: 48px 0; }
  .col-image, .col-text { max-width: 100%; flex: 1 1 auto; }
  .col-text { height: auto; }
  #word { font-size: 3rem; }
  .in-the-wild { padding: 64px 24px; }
  .wild-cards { flex-direction: column; }
}
