/* ------------------------------------------------------------------
   Machado — the pages either side of the editor: sign in, and the
   library of everything you have written. Palette comes from theme.css.
------------------------------------------------------------------- */

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
}

.page-centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.page-scroll { min-height: 100vh; }

/* The wordmark is drawn as a mask rather than an <img>, because an image
   is its own document — the page's colour cannot reach inside it, so the
   artwork stayed black on a dark background. As a mask, the ink is
   painted by CSS and follows the theme. */
.wordmark {
  display: block;
  height: 26px;
  aspect-ratio: 150 / 26;
  background-color: var(--ink);
  -webkit-mask: url('logo.svg') no-repeat center / contain;
  mask: url('logo.svg') no-repeat center / contain;
}

/* ---------------- Sign in ---------------- */

.panel {
  width: 100%;
  max-width: 340px;
}

.panel[hidden] { display: none; }

.panel .wordmark { margin: 0 auto; }

.tagline {
  margin-top: 10px;
  margin-bottom: 34px;
  text-align: center;
  font-family: Literata, Georgia, serif;
  font-size: 15px;
  font-style: italic;
  color: var(--muted);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--muted);
}

.field input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--chrome);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.12s ease;
}

.field input:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  margin-top: 6px;
  cursor: pointer;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.btn-primary:hover:not(:disabled) { opacity: 0.88; }
.btn-primary:active:not(:disabled) { transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.btn-google:hover:not(:disabled) { background: var(--chrome); }
.btn-google:disabled { opacity: 0.5; cursor: default; }

.switch {
  margin-top: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.linkish {
  font: inherit;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0 0 1px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}

.linkish:hover { border-bottom-color: var(--accent); }

.notice {
  margin: 4px 0 12px;
  padding: 9px 11px;
  border-radius: 7px;
  font-size: 13px;
  line-height: 1.45;
}

.notice[hidden] { display: none; }

.notice-error {
  color: #8C2F2F;
  background: #F6E7E5;
  border: 1px solid #E8CFCB;
}

.notice-ok {
  color: #2F5D3A;
  background: #E4EFE6;
  border: 1px solid #CBDFD0;
}

:root[data-theme="dark"] .notice-error {
  color: #E6B4AE;
  background: #2E211F;
  border-color: #45302C;
}

:root[data-theme="dark"] .notice-ok {
  color: #A9CDB2;
  background: #1E2A21;
  border-color: #2D3F32;
}

/* ---------------- Library ----------------
   Structure and proportions follow the design reference exactly; colours
   come from the theme so the page works in daylight too. */

.page-library { background: var(--lib-bg); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 2vw, 16px);
  padding: 0 clamp(14px, 4vw, 24px);
  background-color: var(--header-bg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.wordmark-link {
  display: block;
  color: var(--ink);
  text-decoration: none;
}

/* Quieter here than on the sign-in page — the entries are the subject. */
.topbar .wordmark { height: 20px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.6vw, 8px);
}

.btn-new {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 29px;
  padding: 0 11px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: var(--lib-bg);
  font-family: inherit;
  font-size: clamp(12.5px, 3.4vw, 13.5px);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.btn-new:hover {
  background: var(--dim);
  border-color: var(--dim);
}

.btn-new span {
  font-size: 15px;
  line-height: 1;
  opacity: 0.75;
}

.avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--menu-border);
  border-radius: 50%;
  background: var(--field-bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.avatar:hover {
  background: var(--field-focus);
  border-color: var(--dim);
}

/* ---------------- Dropdowns (account + row actions) ---------------- */

.menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  min-width: 168px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--menu-border);
  border-radius: 10px;
  background: var(--menu-bg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.menu[hidden] { display: none; }

.menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.menu button:hover { background: var(--menu-hover); }
.menu button.danger { color: var(--danger); }

.menu svg {
  width: 14px;
  height: 14px;
  flex: none;
}

/* ---------------- Page shell ---------------- */

.shell {
  width: auto;
  max-width: 800px;
  margin: 0 auto;
  padding: 64px 20px 96px;
}

.list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.list-head h1 {
  font-family: var(--ui-font);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.subtle {
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
}

/* ---------------- Search ---------------- */

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 200px;
  max-width: 260px;
  min-width: 0;
  margin-left: auto;
}

.search input {
  width: 100%;
  height: 34px;
  padding: 0 32px 0 33px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  transition: border-color 120ms ease, background 120ms ease;
}

.search input:hover {
  border-color: var(--field-border);
  background: var(--field-bg);
}

.search input:focus {
  border-color: var(--dim);
  background: var(--field-focus);
}

.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  margin-top: -7px;
  width: 14px;
  height: 14px;
  color: var(--dim);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 7px;
  top: 50%;
  margin-top: -11px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--icon);
  cursor: pointer;
}

.search-clear svg { width: 11px; height: 11px; display: block; }
.search-clear:hover { color: var(--ink); background: var(--menu-border); }
.search-clear[hidden] { display: none; }

/* ---------------- Rows ---------------- */

.rows {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
}

.rows:not(:empty) { border-bottom: 1px solid var(--divider); }

.row {
  position: relative;
  border-top: 1px solid var(--divider);
  transition: background 120ms ease;
}

.row:hover { background: var(--row-hover); }

/* so an open menu paints above the next row's divider and hover fill */
.row.menu-open { z-index: 10; }

.row-open {
  display: block;
  padding: 16px 20px;
  padding-right: 56px;
  color: inherit;
  text-decoration: none;
}

.row-title {
  font-family: var(--read-font);
  font-size: var(--read-title-size);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: var(--read-tracking);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-excerpt {
  margin-top: 4px;
  font-family: var(--read-font);
  font-size: var(--read-excerpt-size);
  font-weight: 400;
  line-height: 1.35;
  color: var(--read-excerpt-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-meta {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--dim);
}

.row-meta .dot { opacity: 0.7; font-size: 12px; }

.row-actions {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.row:hover .row-actions,
.row.menu-open .row-actions,
.row-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
}

.dots {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--icon);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.dots:hover { background: var(--menu-hover); color: var(--ink); }
.dots svg { width: 16px; height: 16px; display: block; }

.row-menu { min-width: 140px; top: calc(100% + 6px); }

/* ---------------- Inline rename ---------------- */

/* Negative margins pull the field's text back into line with the excerpt
   below it, so renaming does not shift the row. */
.rename {
  position: relative;
  width: calc(100% + 14px);
  margin: -5px -7px -2px;
}

.rename input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 4px 38px 4px 6px;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  outline: none;
  background: var(--field-bg);
  font-family: var(--read-font);
  font-size: var(--read-title-size);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: var(--read-tracking);
  color: var(--ink);
}

.rename-ok {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--icon);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.rename-ok:hover { background: var(--menu-hover); color: var(--ok); }
.rename-ok svg { width: 15px; height: 15px; display: block; }

/* ---------------- Empty / error line ---------------- */

.state {
  margin-top: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}

.state[hidden] { display: none; }
.state a { color: var(--accent); text-decoration: none; }
.state a:hover { text-decoration: underline; }

/* ---------------- Pagination ---------------- */

.pager {
  margin-top: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.pager[hidden] { display: none; }

.page-nums {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pager button {
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  transition: color 120ms ease;
}

.pager .arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 28px;
  padding: 0;
  color: var(--icon);
}

.pager .arrow svg { width: 12px; height: 12px; display: block; }
.pager .arrow:disabled { opacity: 0.35; cursor: default; }
.pager .arrow:not(:disabled):hover { color: var(--ink); }

.pager .num {
  min-width: 20px;
  height: 28px;
  padding: 0 2px;
  font-size: 16.5px;
  font-weight: 400;
  color: var(--dim);
}

.pager .num:hover { color: var(--ink); }

.pager .num[aria-current='page'] {
  color: var(--ink);
  font-weight: 500;
}

/* ---------------- Settings ---------------- */

.back {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 120ms ease;
}

.back:hover { color: var(--ink); }
.back svg { width: 12px; height: 12px; display: block; }

.settings-heading {
  font-family: var(--ui-font);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

/* Section labels above each group of settings */
.settings-section {
  margin-top: 30px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.settings-heading + .settings-section { margin-top: 22px; }

.settings-block {
  margin-top: 10px;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 12px;
}

.settings-row + .settings-row { border-top: 1px solid var(--divider); }

.settings-row h2 {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.settings-row p {
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.toggle {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 23px;
  padding: 0;
  border: 1px solid var(--menu-border);
  border-radius: 999px;
  background: var(--toggle-off);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.toggle[aria-checked='true'] {
  background: var(--ok);
  border-color: var(--ok);
}

/* The knob stays light against either track — dark on green reads as off. */
.toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--knob);
  transition: left 140ms ease;
}

.toggle[aria-checked='true'] .knob { left: 20px; }

/* A dropdown built on the app's own menu, because a native one couldn't
   show each option in its typeface. */
.picker {
  position: relative;
  flex: 0 0 auto;
}

.picker-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 132px;
  justify-content: space-between;
  padding: 6px 9px 6px 12px;
  font-family: var(--read-font);
  font-size: 14px;
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: 7px;
  cursor: pointer;
}

.picker-btn svg {
  width: 13px;
  height: 13px;
  color: var(--icon);
}

.picker .menu {
  top: calc(100% + 6px);
  right: 0;
  min-width: 100%;
}

.picker .menu button {
  font-family: var(--read-font);
  line-height: 1.3;
  white-space: nowrap;
}

.picker .menu svg { margin-left: auto; }

/* ---------------- Focus ---------------- */

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- Mobile ---------------- */

@media (max-width: 600px) {
  .wordmark { height: 21px; }
  .topbar .wordmark { height: 18px; }
  .shell { padding: 36px 16px 64px; }
  .list-head h1 { font-size: 22px; }
  .settings-heading { font-size: 23px; }
  .search { flex-basis: 100%; max-width: none; margin-left: 0; margin-top: 14px; }
  .row-open { padding: 14px 16px; padding-right: 50px; }
  .row-actions { right: 12px; }
  /* no hover on touch — keep the actions button reachable */
  .row-actions { opacity: 1; pointer-events: auto; }
}
