:root {
  --bg: #f4efe6;
  --surface: #fff9f1;
  --ink: #1d2a2a;
  --subtle: #586464;
  --primary: #0a7d74;
  --primary-strong: #065a53;
  --accent: #d96b37;
  --danger: #b63f3f;
  --border: #d2c5b3;
  --shadow: 0 12px 30px rgba(16, 46, 45, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, #f8d9b5 0 18%, transparent 19%),
    radial-gradient(circle at 92% 90%, #d5eee6 0 20%, transparent 21%),
    var(--bg);
}

h1,
h2,
h3 {
  font-family: "Fraunces", serif;
  margin: 0;
}

p {
  margin: 0;
}

.page-shell {
  width: min(1100px, 92vw);
  margin: 2rem auto 3rem;
}

.hero {
  background: linear-gradient(135deg, #fff4e2, #f3fcf8);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2rem;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1.35fr 1fr;
}

.eyebrow {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--subtle);
  margin-bottom: 0.35rem;
}

h1 {
  font-size: clamp(2.1rem, 3vw, 2.9rem);
  margin-bottom: 0.75rem;
}

.subtitle {
  max-width: 50ch;
  color: var(--subtle);
}

.hero-side {
  display: grid;
  gap: 0.75rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 0.75rem;
  align-self: end;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem;
}

.stat-value {
  display: block;
  font-weight: 700;
  font-size: 1.4rem;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--subtle);
}

.tabs {
  margin-top: 1.1rem;
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.tab.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.panel {
  display: none;
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.panel.is-active {
  display: block;
}

.panel-copy {
  color: var(--subtle);
  margin-top: 0.35rem;
}

.sync-inline {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.86);
  padding: 0.7rem;
  display: grid;
  gap: 0.55rem;
}

.sync-title {
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtle);
  font-weight: 700;
}

.sync-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.sync-status {
  font-size: 0.8rem;
  color: var(--subtle);
}

.vocab-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.9rem;
}

label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
}

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

input,
textarea,
select {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  outline: 2px solid #1ea89c;
  outline-offset: 1px;
}

.form-actions {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
}

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

.btn-primary:hover {
  background: var(--primary-strong);
}

#formMessage {
  color: var(--subtle);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.utility-buttons {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.file-btn input {
  display: none;
}

.library-controls {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: minmax(180px, 1fr) 160px 170px;
}

.styled-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.2rem;
  border-width: 1.5px;
  background:
    linear-gradient(45deg, transparent 50%, #4f6766 50%),
    linear-gradient(135deg, #4f6766 50%, transparent 50%),
    #fff;
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px),
    0 0;
  background-size:
    6px 6px,
    6px 6px,
    100% 100%;
  background-repeat: no-repeat;
}

.library-list {
  margin-top: 1rem;
  display: grid;
  gap: 0.85rem;
}

.word-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.95rem;
}

.word-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.word-title {
  font-size: 1.25rem;
}

.word-box {
  font-size: 0.78rem;
  border: 1px solid #b8c8c8;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  color: #2f5553;
}

.word-meaning {
  margin-top: 0.5rem;
}

.word-example {
  margin-top: 0.35rem;
  color: var(--subtle);
  font-style: italic;
}

.word-tags {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-size: 0.75rem;
  border: 1px solid #bdd8d5;
  background: #e8f8f5;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.word-meta {
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--subtle);
}

.word-actions {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.5rem;
  justify-content: end;
  flex-wrap: wrap;
}

.btn-small {
  font-size: 0.82rem;
}

.delete-btn {
  color: var(--danger);
  border-color: #e5b6b6;
  background: #fff2f2;
}

.toggle-memory-btn {
  color: #1b5e58;
  border-color: #b9ddd9;
  background: #effaf8;
}

.empty-list,
.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  border: 1px dashed #b7b7b7;
  border-radius: 14px;
  color: var(--subtle);
}

.study-wrap {
  margin-top: 1rem;
}

.study-progress {
  color: var(--subtle);
  margin-bottom: 0.55rem;
}

.study-status {
  color: #1b5e58;
  font-weight: 600;
  margin-bottom: 0.65rem;
}

.flashcard {
  background: linear-gradient(160deg, #fff 0%, #fffbf3 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.2rem;
  min-height: 220px;
}

.flashcard-label {
  color: var(--subtle);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

#flashWord {
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  margin-top: 0.3rem;
}

.meaning-area {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed #c5cbc8;
}

#flashMeaning {
  margin-top: 0.35rem;
}

.flash-example {
  margin-top: 0.45rem;
  color: var(--subtle);
  font-style: italic;
}

.study-actions {
  margin-top: 0.85rem;
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.manual-study-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

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

  .library-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(96vw, 1100px);
    margin-top: 1rem;
  }

  .hero,
  .panel {
    border-radius: 16px;
    padding: 1rem;
  }
}
