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

:root {
  --bg: #F8F6F3;
  --surface: #FFFFFF;
  --accent: #E8734A;
  --accent-light: #FFF0E8;
  --text: #3D3425;
  --text-muted: #8B7355;
  --border: #E8E0D6;
  --success: #38A169;
  --warning: #D69E2E;
  --danger: #E53E3E;
  --radius: 14px;
  --transition: 0.25s ease;
}

body {
  font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
.admin-header {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 1rem 1.5rem;
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem;
}
.admin-header h1 {
  font-size: 1.3rem; font-weight: 700; color: var(--accent);
}
.preview-link {
  font-size: 0.85rem; font-weight: 600; color: var(--accent);
  text-decoration: none; padding: 0.4rem 1rem;
  border: 2px solid var(--accent); border-radius: 50px;
  transition: var(--transition);
}
.preview-link:hover {
  background: var(--accent); color: #fff;
}

/* ── Main ── */
.admin-main {
  max-width: 900px; margin: 0 auto; padding: 1.5rem;
}

/* ── Section ── */
.section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  border: 1px solid var(--border);
}
.section h2 {
  font-size: 1.15rem; font-weight: 700; color: var(--text);
  margin-bottom: 1rem;
}
.section h3 {
  font-size: 0.95rem; font-weight: 600; color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem;
}
.section-header h2 { margin-bottom: 0; }

/* ── Inputs ── */
.input, .textarea {
  font-family: inherit; font-size: 0.9rem;
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  transition: var(--transition);
  outline: none;
}
.input:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.input-sm { max-width: 120px; }
.input-full { width: 100%; }
.textarea {
  width: 100%; resize: vertical;
  font-family: 'Noto Sans TC', monospace;
  line-height: 1.7;
}

.hint {
  font-size: 0.8rem; color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.hint code {
  background: var(--accent-light); padding: 0.1rem 0.4rem;
  border-radius: 4px; font-size: 0.78rem;
}

/* ── Buttons ── */
.btn {
  font-family: inherit; font-size: 0.88rem; font-weight: 600;
  padding: 0.55rem 1.2rem;
  border-radius: 10px; border: 2px solid transparent;
  cursor: pointer; transition: var(--transition);
  display: inline-flex; align-items: center; gap: 0.3rem;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(232,115,74,0.2);
}
.btn-accent {
  background: #6B46C1; color: #fff;
  box-shadow: 0 2px 8px rgba(107,70,193,0.2);
}
.btn-outline {
  background: transparent; color: var(--text-muted);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
  background: transparent; color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { font-size: 0.78rem; padding: 0.35rem 0.7rem; }

/* ── Forms ── */
.week-create-form {
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
}
.word-add-form, .batch-input-wrap {
  padding: 1rem; background: #FAFAF7; border-radius: 12px;
  border: 1px dashed var(--border); margin-bottom: 1rem;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.settings-row label {
  font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
}
.settings-input-group {
  display: flex; gap: 0.4rem; align-items: center;
}
.settings-input-group .input { width: 80px; text-align: center; }

.batch-input-wrap { margin-bottom: 1rem; }
.form-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.form-row .input { flex: 1; min-width: 150px; }
.word-add-form .input-full { margin-bottom: 0.5rem; }

/* ── Week list ── */
.week-list { margin-top: 1rem; }
.week-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1rem; border-radius: 10px;
  margin-bottom: 0.5rem; cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  flex-wrap: wrap; gap: 0.5rem;
}
.week-item:hover { background: var(--accent-light); }
.week-item.selected {
  background: var(--accent-light);
  border-color: var(--accent);
}
.week-item.active-week {
  border-left: 4px solid var(--success);
}
.week-info { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.week-name { font-weight: 600; }
.week-date { font-size: 0.8rem; color: var(--text-muted); }
.week-stats {
  font-size: 0.78rem; color: var(--text-muted);
  background: rgba(0,0,0,0.04); padding: 0.2rem 0.6rem;
  border-radius: 6px;
}
.week-actions { display: flex; gap: 0.4rem; }
.active-badge {
  font-size: 0.72rem; font-weight: 700; color: var(--success);
  background: #F0FFF4; padding: 0.15rem 0.5rem; border-radius: 6px;
}

/* ── Word list ── */
.word-list { margin-top: 0.5rem; }
.word-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1rem; border-radius: 10px;
  margin-bottom: 0.5rem;
  background: #FAFAF7;
  border: 1px solid var(--border);
  flex-wrap: wrap; gap: 0.5rem;
  transition: var(--transition);
}
.word-item:hover { border-color: var(--accent); }
.word-main { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; flex: 1; }
.word-emoji {
  font-size: 1.4rem; cursor: pointer;
  border-radius: 8px; padding: 0.2rem;
  transition: 0.2s ease;
}
.word-emoji:hover { background: var(--accent-light); }
.word-name { font-weight: 700; font-size: 1rem; color: var(--accent); }
.word-sentence { font-size: 0.82rem; color: var(--text-muted); max-width: 400px; }
.word-actions { display: flex; gap: 0.4rem; align-items: center; }

/* Status badges */
.status-badge {
  font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.5rem;
  border-radius: 6px; text-transform: uppercase;
}
.status-pending { background: #FEFCBF; color: #975A16; }
.status-generating { background: #E9D8FD; color: #553C9A; animation: pulse 1s infinite; }
.status-completed { background: #C6F6D5; color: #276749; }
.status-failed { background: #FED7D7; color: #9B2C2C; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  padding: 0.7rem 1.2rem; border-radius: 10px;
  font-size: 0.85rem; font-weight: 600;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.toast-success { background: #F0FFF4; color: #276749; border: 1px solid #9AE6B4; }
.toast-error { background: #FFF5F5; color: #9B2C2C; border: 1px solid #FEB2B2; }
.toast-info { background: #EBF8FF; color: #2A4365; border: 1px solid #90CDF4; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .admin-main { padding: 1rem; }
  .section { padding: 1rem; }
  .week-create-form .input { width: 100%; }
}
