:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-soft: #f0f0ec;
  --text: #181817;
  --muted: #777770;
  --border: #deded8;
  --accent: #181817;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(20, 20, 15, 0.07);
  --radius: 18px;
  --max: 960px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  padding-bottom: 80px;
}

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand {
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  padding: 0;
}

.brand-static {
  margin-bottom: 34px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: block;
  object-fit: contain;
}

nav {
  display: flex;
  gap: 5px;
}

.nav-link,
.text-btn,
.back-btn,
.new-note-link {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.nav-link {
  padding: 8px 12px;
  border-radius: 8px;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--surface-soft);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.hero {
  text-align: center;
  padding: 110px 0 90px;
  max-width: 720px;
  margin: auto;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.hero h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: clamp(42px, 7vw, 72px);
  line-height: 0.98;
  letter-spacing: -0.045em;
  margin: 16px 0 22px;
}

.hero-copy {
  color: var(--muted);
  max-width: 560px;
  margin: auto;
  font-size: 16px;
}

.search-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 22px;
  border-radius: var(--radius);
  margin: 38px auto 16px;
}

.search-card label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 9px;
}

.search-row {
  display: flex;
  gap: 10px;
}

.search-row input,
.list-search,
#passwordInput,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.search-row input {
  font-size: 22px;
  letter-spacing: .12em;
  padding: 13px 15px;
  text-transform: lowercase;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #9c9c94;
  box-shadow: 0 0 0 4px rgba(20, 20, 15, .05);
}

.primary-btn,
.secondary-btn,
.danger-btn {
  border-radius: 10px;
  padding: 11px 17px;
  border: 1px solid var(--border);
  transition: transform .12s, opacity .12s;
}

.primary-btn {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.secondary-btn {
  background: var(--surface);
  color: var(--text);
}

.danger-btn {
  background: var(--surface);
  color: var(--danger);
  border-color: #e5c7c4;
}

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

.new-note-link {
  font-size: 14px;
  padding: 10px;
}

.new-note-link span {
  font-size: 20px;
  vertical-align: -1px;
  margin-right: 4px;
}

.recent-section {
  padding-bottom: 40px;
}

.section-heading,
.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-heading h2,
.page-heading h1 {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -.03em;
}

.page-heading {
  padding-top: 60px;
}

.page-heading h1 {
  font-size: 42px;
}

.text-btn {
  font-size: 13px;
}

.note-list {
  display: grid;
  gap: 8px;
}

.note-row {
  width: 100%;
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 18px;
  align-items: center;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px 18px;
  color: var(--text);
}

.note-row:hover {
  border-color: #bdbdb5;
  box-shadow: 0 8px 24px rgba(20,20,15,.04);
}

.row-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
}

.row-preview {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #45453f;
}

.row-date {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 13px;
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.list-search {
  padding: 11px 13px;
}

select {
  max-width: 180px;
  padding: 11px 13px;
}

.editor-top,
.note-page-top {
  padding-top: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-btn {
  font-size: 13px;
}

.editor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 25px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.editor-header {
  padding: 28px 30px 18px;
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.editor-header h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: 30px;
  margin: 6px 0 0;
}

.code-preview,
.large-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
}

.code-preview {
  color: var(--muted);
  font-size: 13px;
  padding: 7px 10px;
  background: var(--surface-soft);
  border-radius: 8px;
}

textarea {
  display: block;
  width: 100%;
  min-height: 430px;
  resize: vertical;
  border: 0;
  border-top: 1px solid var(--border);
  outline: 0;
  padding: 28px 30px;
  color: var(--text);
  background: var(--surface);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.75;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.editor-actions,
.note-actions {
  display: flex;
  gap: 8px;
}

.note-page {
  max-width: 760px;
  margin: auto;
}

.note-meta {
  text-align: center;
  padding: 75px 0 55px;
}

.large-code {
  border: 0;
  background: transparent;
  font-size: 31px;
  font-weight: 700;
  margin: 10px 0 6px;
  padding: 4px 9px;
  color: var(--text);
}

.large-code:hover {
  background: var(--surface-soft);
  border-radius: 8px;
}

.note-date {
  color: var(--muted);
  font-size: 12px;
}

.note-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 38px;
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.8;
  min-height: 260px;
}

.settings-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 10px;
}

.settings-card h3 {
  margin: 0 0 5px;
}

.settings-card p,
.settings-note {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.danger-zone {
  border-color: #e5c7c4;
}

.settings-note {
  margin-top: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(247,247,245,.88);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

.password-modal {
  width: min(100%, 390px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.password-modal h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 500;
  margin: 10px 0 7px;
}

.password-modal p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

#passwordInput {
  padding: 12px 13px;
  margin-bottom: 10px;
}

.full-btn {
  width: 100%;
}

.login-error {
  color: var(--danger);
  font-size: 12px;
  min-height: 18px;
  margin-top: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: #181817;
  color: white;
  padding: 10px 15px;
  border-radius: 9px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 650px) {
  .app-shell {
    width: min(calc(100% - 24px), var(--max));
  }

  .topbar {
    height: 70px;
  }

  nav {
    gap: 0;
  }

  .nav-link {
    padding: 7px 8px;
    font-size: 12px;
  }

  .hero {
    padding: 75px 0 60px;
  }

  .hero h1 {
    font-size: 45px;
  }

  .search-row {
    flex-direction: column;
  }

  .search-row .primary-btn {
    width: 100%;
  }

  .section-heading,
  .page-heading {
    align-items: start;
    flex-direction: column;
  }

  .note-row {
    grid-template-columns: 70px 1fr;
  }

  .row-date {
    display: none;
  }

  .toolbar {
    flex-direction: column;
  }

  select {
    max-width: none;
  }

  .editor-header,
  .editor-footer {
    gap: 15px;
  }

  .editor-header {
    padding: 22px;
  }

  textarea {
    padding: 22px;
    min-height: 380px;
  }

  .editor-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-actions {
    justify-content: stretch;
  }

  .editor-actions button {
    flex: 1;
  }

  .note-page-top {
    padding-top: 30px;
  }

  .note-meta {
    padding: 55px 0 35px;
  }

  .note-content {
    padding: 24px;
  }

  .settings-card {
    align-items: start;
    flex-direction: column;
  }
}
