/* ============================================================
   RESET & VARIABLES
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #f5f2ed;
  --surface:      #ffffff;
  --surface2:     #f9f7f3;
  --border:       #e4dfd7;
  --border-light: #ede9e3;
  --text:         #111111;
  --text-mid:     #555550;
  --text-muted:   #888880;
  --text-light:   #bbb8b2;
  --tag-bg:       #eeebe5;
  --serif:        'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius:       10px;
  --shadow:       0 4px 20px rgba(0,0,0,0.07);
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  height: 52px;
  gap: 0;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  margin-right: 40px;
}

.nav-logo svg { color: var(--text); }

.nav-links {
  display: flex;
  gap: 28px;
  flex: 1;
}

.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  transition: color 0.15s;
  padding: 4px 0;
  border-bottom: 1.5px solid transparent;
}
.nav-link:hover { color: var(--text-mid); }
.nav-link.active {
  color: var(--text);
  font-weight: 500;
  border-bottom-color: var(--text);
}


/* ============================================================
   MAIN LAYOUT
   ============================================================ */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 32px 80px;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 52px;
  line-height: 1.08;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 8px;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* ============================================================
   SHARED COMPONENTS
   ============================================================ */
.filter-tabs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.filter-tab {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 15px;
  border-radius: 20px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}
.filter-tab.active, .filter-tab:hover {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--tag-bg);
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: var(--text);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: var(--sans);
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.8; }

.btn-outline {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.15s;
}
.btn-outline:hover { background: var(--text); color: #fff; border-color: var(--text); }

select.styled {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 32px 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
  transition: border-color 0.15s;
}
select.styled:focus { border-color: var(--text); }

/* ============================================================
   COMPARE PAGE
   ============================================================ */
.compare-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.control-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.size-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
input[type="range"].slider {
  -webkit-appearance: none;
  width: 90px;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  background: var(--text);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}
input[type="range"].slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.size-val {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 30px;
}

.toggle-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface);
}
.toggle-btn {
  background: none;
  border: none;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.15s;
  line-height: 1;
}
.toggle-btn + .toggle-btn { border-left: 1px solid var(--border); }
.toggle-btn.active { background: var(--text); color: #fff; }

.compare-add-btn {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.15s;
  white-space: nowrap;
}
.compare-add-btn:hover { background: var(--text); color: #fff; border-color: var(--text); }

/* Table */
.compare-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  overflow-x: auto;
}
.compare-wrap.dark-bg {
  background: #181818;
  border-color: #2c2c2c;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
.compare-table thead th {
  background: var(--bg);
  padding: 10px 18px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-family: var(--sans);
}
.compare-wrap.dark-bg thead th {
  background: #111;
  border-color: #2c2c2c;
  color: #666;
}
.compare-table thead th:first-child { min-width: 200px; width: 200px; }
.compare-table thead th:not(:first-child) { min-width: 100px; }

.compare-table tbody td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.compare-wrap.dark-bg tbody td { border-color: #242424; }
.compare-table tbody tr:last-child td { border-bottom: none; }
.compare-table tbody tr:hover td { background: var(--surface2); }
.compare-wrap.dark-bg tbody tr:hover td { background: #202020; }

.font-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.font-cell-info { flex: 1; min-width: 0; }
.font-cell-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-wrap.dark-bg .font-cell-name { color: #e0e0e0; }
.font-cell-cat {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.remove-row-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 15px;
  line-height: 1;
  opacity: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}
tr:hover .remove-row-btn { opacity: 1; }
.remove-row-btn:hover { background: #fee; color: #d03; }
.compare-wrap.dark-bg .remove-row-btn:hover { background: #3a1515; color: #f06; }

.glyph {
  font-size: 26px;
  line-height: 1;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: 0.05em;
}
.compare-wrap.dark-bg .glyph { color: #e4e4e4; }

/* Sentence context */
.sentence-section {
  margin-top: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.sentence-section.dark-bg {
  background: #181818;
  border-color: #2c2c2c;
}

.section-heading {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--sans);
}
.sentence-section.dark-bg .section-heading { border-color: #2c2c2c; color: #555; }

.sentence-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
}
.sentence-section.dark-bg .sentence-row { border-color: #242424; }
.sentence-row:last-child { border-bottom: none; }

.sentence-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-light);
  white-space: nowrap;
  min-width: 130px;
  flex-shrink: 0;
}
.sentence-section.dark-bg .sentence-label { color: #555; }
.sentence-text {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
}
.sentence-section.dark-bg .sentence-text { color: #d8d8d8; }

/* Empty compare state */
.compare-empty {
  text-align: center;
  padding: 60px 40px;
  color: var(--text-muted);
}
.compare-empty p { margin-bottom: 16px; font-size: 15px; }

/* ============================================================
   SPECIMENS PAGE
   ============================================================ */
.specimen-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}
.specimen-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.specimen-meta { font-size: 13px; color: var(--text-muted); }

.font-picker {
  position: relative;
}
.font-picker-input {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 32px 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 220px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.font-picker-input:focus { border-color: var(--text); cursor: text; }
.font-picker-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  z-index: 200;
}
.font-picker-dropdown.is-open { display: block; }
.font-picker-item {
  height: 32px;
  line-height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
}
.font-picker-item:hover { background: var(--bg); }
.font-picker-item.is-selected { font-weight: 600; }

.specimen-block {
  margin-bottom: 40px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border-light);
}
.specimen-block:last-child { border-bottom: none; margin-bottom: 0; }

.block-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 18px;
  font-family: var(--sans);
}
.spec-line { line-height: 1.3; color: var(--text); }
.spec-line + .spec-line { margin-top: 10px; }

.pangram-ramp .pramp + .pramp { margin-top: 14px; }

/* ============================================================
   GOOGLE FONTS PAGE
   ============================================================ */
.gfonts-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.gfonts-count { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.search-field {
  position: relative;
  margin-bottom: 20px;
}
.search-field svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.search-field input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 16px 10px 42px;
  border-radius: 9px;
  font-size: 14px;
  font-family: var(--sans);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.search-field input:focus { border-color: var(--text-mid); }
.search-field input::placeholder { color: var(--text-light); }

.fonts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 900px) {
  .fonts-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .fonts-grid { grid-template-columns: 1fr; }
  main { padding: 28px 16px 60px; }
  .navbar { padding: 0 16px; gap: 0; }
  .nav-links { gap: 16px; }
  .page-title { font-size: 38px; }
}

.font-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.font-card:hover { border-color: #ccc; box-shadow: 0 2px 12px rgba(0,0,0,0.07); }

.font-card-preview {
  background: var(--surface2);
  padding: 24px 20px;
  text-align: center;
  font-size: 30px;
  color: var(--text);
  line-height: 1.3;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.font-card-footer {
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
  gap: 8px;
}
.font-card-name { font-size: 13px; font-weight: 500; color: var(--text); }
.font-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.font-card-add {
  background: var(--text);
  color: #fff;
  border: none;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: var(--sans);
  transition: opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.font-card-add.is-loaded {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.font-card-add:hover { opacity: 0.8; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20,18,14,0.45);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 520px;
  max-width: 92vw;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-search-wrap {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
}
.modal-search-wrap input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--sans);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.modal-search-wrap input:focus { border-color: var(--text-mid); }
.modal-search-wrap input::placeholder { color: var(--text-light); }

.modal-font-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}
.modal-font-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.modal-font-item:hover { background: var(--surface2); }
.modal-font-item.is-added {
  opacity: 0.45;
  pointer-events: none;
}
.modal-font-item-name { font-size: 13px; color: var(--text); font-weight: 500; }
.modal-font-item-preview { font-size: 17px; color: var(--text-muted); }


/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 40px;
}
.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  transition: all 0.15s;
}
.page-btn:hover:not(:disabled) { background: var(--text); color: #fff; border-color: var(--text); }
.page-btn:disabled { opacity: 0.35; cursor: default; }
.page-info { font-size: 13px; color: var(--text-muted); }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }
