:root {
  --bg: #e0e5ec;
  --fg: #2b2f3a;
  --accent: #4f6df5;
  --shadow-light: rgba(255, 255, 255, 0.8);
  --shadow-dark: rgba(163, 177, 198, 0.7);
  --radius-lg: 18px;
  --radius-md: 12px;
  --transition-fast: 0.18s ease-out;
}

:root.dark {
  --bg: #1f1f24;
  --fg: #f0f0f5;
  --shadow-light: rgba(255, 255, 255, 0.06);
  --shadow-dark: rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(circle at top left, #f5f7fb, var(--bg));
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
  transition: background 0.3s, color 0.3s;
}

.app {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.neu-card {
  background: rgba(224, 229, 236, 0.9);
  border-radius: var(--radius-lg);
  box-shadow:
    -10px -10px 20px var(--shadow-light),
    10px 10px 20px var(--shadow-dark);
  padding: 20px;
  transition: background 0.3s, box-shadow 0.3s, transform 0.2s;
}

:root.dark .neu-card {
  background: rgba(31, 31, 36, 0.9);
}

.neu-card:hover {
  transform: translateY(-1px);
}

/* Header */
.app-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.app-title {
  font-size: 1.8rem;
  font-weight: 600;
}

.app-subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
  line-height: 1.5;
}

/* Theme toggle */
.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-label {
  font-size: 0.85rem;
  opacity: 0.8;
}

.theme-toggle input {
  display: none;
}

.theme-pill {
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
  padding: 3px;
  display: flex;
  align-items: center;
  transition: 0.3s;
}

.theme-knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.2s;
}

.theme-toggle input:checked + .theme-pill .theme-knob {
  transform: translateX(20px);
}

/* Layout */
.layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 860px) {
  .layout {
    flex-direction: row;
  }
  .controls {
    flex: 0 0 380px;
  }
  .preview {
    flex: 1;
  }
}

/* Sections */
.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.7;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.neu-input-group {
  margin-bottom: 16px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.row-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Font select button */
.font-select-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: var(--bg);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
  font-size: 0.8rem;
  transition: 0.2s;
}

.font-select-btn:hover {
  transform: translateY(-1px);
}

/* Weight select */
.weight-select {
  border-radius: 999px;
  border: none;
  padding: 4px 10px;
  font-size: 0.8rem;
  background: var(--bg);
  box-shadow:
    -3px -3px 6px var(--shadow-light),
    3px 3px 6px var(--shadow-dark);
  color: var(--fg);
}

/* Lock toggle */
.lock-toggle input {
  display: none;
}

.lock-pill {
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    -3px -3px 6px var(--shadow-light),
    3px 3px 6px var(--shadow-dark);
  padding: 2px;
  display: flex;
  align-items: center;
}

.lock-knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #c3ccd9;
  transition: transform 0.2s, background 0.2s;
}

.lock-toggle input:checked + .lock-pill .lock-knob {
  transform: translateX(14px);
  background: var(--accent);
}

/* Inputs */
.neu-input {
  width: 100%;
  border: none;
  outline: none;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.9rem;
  background: var(--bg);
  box-shadow:
    inset -4px -4px 8px var(--shadow-light),
    inset 4px 4px 8px var(--shadow-dark);
  color: var(--fg);
  resize: vertical;
}

/* Category filter */
.category-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.category-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
  cursor: pointer;
  font-size: 0.85rem;
}

.category-pill input {
  display: none;
}

.category-pill input:checked + span {
  color: var(--accent);
  font-weight: 600;
}

/* Slider */
.slider-wrap {
  margin-bottom: 16px;
}

.slider-wrap.small {
  margin-top: 8px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  opacity: 0.8;
  margin-bottom: 4px;
}

.neu-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    inset -4px -4px 8px var(--shadow-light),
    inset 4px 4px 8px var(--shadow-dark);
}

.neu-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    -3px -3px 6px var(--shadow-light),
    3px 3px 6px var(--shadow-dark);
}

/* Buttons */
.neu-button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.neu-button {
  border: none;
  outline: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--bg);
  box-shadow:
    -6px -6px 12px var(--shadow-light),
    6px 6px 12px var(--shadow-dark);
  color: var(--fg);
  transition: 0.2s;
}

.neu-button.small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.neu-button.primary {
  background: linear-gradient(135deg, #4f6df5, #7a8cff);
  color: #fff;
}

.neu-button:active {
  transform: translateY(1px);
}

/* Preview */
.preview-card {
  padding: 20px;
}

.preview-heading {
  margin: 0 0 8px;
}

.preview-subheading {
  margin: 0 0 10px;
}

.preview-body {
  line-height: 1.7;
}

.font-tag {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-bottom: 10px;
}

/* Code card */
.code-card {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Font detail */
.font-detail-card {
  margin-top: 16px;
}

#font-detail {
  font-size: 0.85rem;
  line-height: 1.6;
}

#font-detail a {
  color: var(--accent);
  text-decoration: none;
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.history-item {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow:
    -3px -3px 6px var(--shadow-light),
    3px 3px 6px var(--shadow-dark);
  font-size: 0.8rem;
  cursor: pointer;
}

/* Footer */
.footer {
  margin-top: 20px;
}

.footer-inner {
  text-align: center;
  padding: 14px;
}

.footer-link {
  text-decoration: none;
  color: var(--fg);
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    -6px -6px 12px var(--shadow-light),
    6px 6px 12px var(--shadow-dark);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(16px);
}

.modal-animate {
  animation: modalIn 0.18s ease-out;
}

@keyframes modalIn {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--fg);
}

.modal-preview {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow:
    inset -4px -4px 8px var(--shadow-light),
    inset 4px 4px 8px var(--shadow-dark);
  font-size: 1rem;
}

.modal-search {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: none;
  outline: none;
  background: var(--bg);
  box-shadow:
    inset -4px -4px 8px var(--shadow-light),
    inset 4px 4px 8px var(--shadow-dark);
  color: var(--fg);
  font-size: 0.9rem;
}

.modal-tabs {
  display: flex;
  gap: 10px;
}

.modal-tab {
  flex: 1;
  padding: 8px 0;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: var(--bg);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
  font-size: 0.85rem;
}

.modal-tab.active {
  background: var(--accent);
  color: #fff;
}

.modal-font-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.font-item {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.font-item:hover {
  transform: translateY(-2px);
}

.font-item-left {
  display: flex;
  flex-direction: column;
}

.font-item-name {
  font-weight: 500;
}

.font-item-tag {
  font-size: 0.75rem;
  opacity: 0.7;
}

.font-fav-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  color: #f5c542;
}
