:root {
  --ink: #20282b;
  --muted: #728080;
  --paper: #f4f6f5;
  --white: #fff;
  --green: #356b5b;
  --green-dark: #254f43;
  --green-soft: #e5f0ec;
  --line: #e2e8e5;
  --yellow-soft: #fff6d9;
  --shadow: 0 12px 40px rgba(29, 56, 46, .07);
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted, .small { color: var(--muted); }
.small { font-size: .9rem; }
.app-shell { min-height: 100vh; }
.brand-row { display: flex; align-items: center; gap: 11px; font: 700 1.28rem Manrope, sans-serif; letter-spacing: -.04em; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--green); color: white; font: 800 1rem Manrope, sans-serif; }
.eyebrow { color: var(--green); font-size: .74rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 42px; border: 0; border-radius: 11px; padding: 0 15px; font-weight: 650; transition: transform .12s ease, background .12s ease, box-shadow .12s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--green); box-shadow: 0 5px 13px rgba(53, 107, 91, .17); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--green-dark); background: var(--green-soft); }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: white; font-size: 1.35rem; }
.text-button, .sign-out { border: 0; padding: 0; color: var(--green); background: none; font-weight: 600; }
.text-button:hover, .sign-out:hover { color: var(--green-dark); text-decoration: underline; }

/* Setup and sign-in */
.setup-screen, .auth-screen { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 15%, #e8f1ec 0, transparent 34%), var(--paper); }
.setup-card, .auth-card { width: min(100%, 465px); border: 1px solid var(--line); border-radius: 22px; padding: 36px; background: var(--white); box-shadow: var(--shadow); }
.setup-card .brand-mark { margin-bottom: 24px; }
.setup-card h1, .auth-card h1 { margin: 8px 0 10px; font: 750 2rem/1.15 Manrope, sans-serif; letter-spacing: -.05em; }
.setup-card p { line-height: 1.65; }
.setup-card code { padding: 2px 5px; border-radius: 5px; background: #f0f3f1; }
.auth-card .brand-row { margin-bottom: 34px; }
.auth-copy { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.auth-form, .new-note-form { display: grid; gap: 10px; }
.auth-form label, .new-note-form label { margin-top: 7px; color: #4d5c5a; font-size: .88rem; font-weight: 650; }
.auth-form input, .new-note-form input, .new-note-form select { min-height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; outline: none; color: var(--ink); background: #fcfdfc; }
.auth-form input:focus, .new-note-form input:focus, .new-note-form select:focus { border-color: #83ac9e; box-shadow: 0 0 0 3px rgba(53,107,91,.11); }
.auth-form .button { margin-top: 8px; min-height: 46px; }
.auth-actions { display: flex; justify-content: space-between; gap: 16px; margin-top: 18px; }
.auth-actions .text-button { font-size: .86rem; }
.message { min-height: 22px; margin: 12px 0 0; color: var(--green-dark); font-size: .9rem; }
.message.error, .workspace-message.error { color: #a94035; }
.privacy-note { margin-top: 20px; border-radius: 12px; padding: 13px 14px; color: #5d6250; background: var(--yellow-soft); font-size: .82rem; line-height: 1.5; }

/* Main application */
.workspace { display: grid; min-height: 100vh; grid-template-columns: 258px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; border-right: 1px solid var(--line); padding: 26px 18px 18px; background: #fbfcfb; }
.sidebar .brand-row { padding: 0 10px; }
.new-note { width: 100%; margin: 31px 0 31px; min-height: 46px; }
.new-note span { font-size: 1.25rem; line-height: 0; }
.nav-label { margin: 0 10px 12px; color: #93a09c; font-size: .68rem; font-weight: 700; letter-spacing: .14em; }
.category-list { display: grid; gap: 4px; }
.category { display: flex; align-items: center; gap: 11px; min-height: 42px; border: 0; border-radius: 9px; padding: 0 11px; color: #60706d; background: transparent; text-align: left; font-size: .91rem; }
.category:hover { color: var(--green-dark); background: #f0f5f2; }
.category.active { color: var(--green-dark); background: var(--green-soft); font-weight: 700; }
.nav-icon { width: 17px; color: #7c928b; text-align: center; font-size: 1rem; }
.category.active .nav-icon { color: var(--green); }
.count { margin-left: auto; color: #83928d; font-size: .75rem; }
.sidebar-bottom { margin-top: auto; }
.privacy-mini { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 17px 7px 16px; color: #53645f; font-size: .83rem; font-weight: 650; line-height: 1.45; }
.privacy-mini small { color: #92a09b; font-size: .75rem; font-weight: 400; }
.lock-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--green); background: var(--green-soft); }
.sign-out { width: 100%; padding: 8px 7px; color: #77847f; text-align: left; font-size: .84rem; }
.main-area { min-width: 0; }
.topbar { position: sticky; z-index: 2; top: 0; display: flex; height: 76px; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); padding: 0 4.5vw; background: rgba(255,255,255,.87); backdrop-filter: blur(14px); }
.search-wrap { display: flex; width: min(550px, 100%); height: 41px; align-items: center; gap: 9px; border: 1px solid #e8ecea; border-radius: 10px; padding: 0 11px; background: #f8faf9; }
.search-icon { color: #8b9894; font-size: 1.6rem; line-height: .8; transform: rotate(-20deg); }
.search-wrap input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: .88rem; }
.search-wrap input::placeholder { color: #a1aca8; }
kbd { border: 1px solid #e1e7e3; border-radius: 5px; padding: 2px 5px; color: #9aa6a1; background: white; font: .67rem 'DM Sans', sans-serif; white-space: nowrap; }
.top-new { margin-left: auto; min-height: 40px; }
.mobile-brand, .mobile-logout { display: none; }
.content-area { width: min(1100px, 91%); margin: 0 auto; padding: 38px 0 60px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading .eyebrow { margin: 0 0 8px; }
.page-heading h1 { margin: 0; font: 750 clamp(1.8rem, 3vw, 2.45rem)/1.13 Manrope, sans-serif; letter-spacing: -.055em; }
.page-heading p.muted { margin: 9px 0 0; font-size: .95rem; }
.user-chip { display: flex; align-items: center; gap: 9px; color: #63716d; font-size: .84rem; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--green-dark); background: #e3eee9; font-weight: 700; text-transform: uppercase; }
.privacy-banner { display: flex; align-items: center; gap: 10px; border: 1px solid #e6eee9; border-radius: 11px; padding: 12px 14px; color: #66756f; background: #f9fbf9; font-size: .83rem; line-height: 1.45; }
.privacy-banner > span:first-child { color: var(--green); font-size: 1.1rem; }
.privacy-banner strong { color: #486357; font-weight: 650; }
.notes-toolbar { display: flex; align-items: center; justify-content: space-between; margin: 26px 1px 13px; color: #77847f; font-size: .82rem; }
.toolbar-actions { display: flex; align-items: center; gap: 15px; }
.sort-button { border: 0; padding: 7px 0 7px 8px; color: #74817c; background: none; font-size: .8rem; }
.notes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.note-card { position: relative; display: flex; min-height: 184px; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; padding: 17px; background: white; box-shadow: 0 4px 15px rgba(35,52,45,.025); transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; cursor: pointer; }
.note-card:hover { transform: translateY(-2px); border-color: #cedbd4; box-shadow: 0 12px 25px rgba(35,52,45,.07); }
.note-card:focus { outline: 3px solid rgba(53,107,91,.25); outline-offset: 2px; }
.note-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note-category { display: inline-flex; align-items: center; min-height: 23px; border-radius: 7px; padding: 0 8px; color: #537265; background: #edf4f0; font-size: .69rem; font-weight: 650; }
.note-actions { display: flex; gap: 3px; opacity: .2; transition: opacity .12s ease; }
.note-card:hover .note-actions, .note-card:focus-within .note-actions { opacity: 1; }
.note-action { display: grid; place-items: center; width: 29px; height: 29px; border: 0; border-radius: 7px; color: #83908b; background: transparent; font-size: 1rem; }
.note-action:hover { color: var(--green-dark); background: #f0f5f2; }
.note-title { display: -webkit-box; overflow: hidden; margin: 12px 0 7px; font: 700 1.02rem/1.35 Manrope, sans-serif; letter-spacing: -.025em; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.note-preview { display: -webkit-box; overflow: hidden; margin: 0; color: #7b8782; font-size: .82rem; line-height: 1.48; white-space: pre-wrap; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.note-date { margin-top: auto; padding-top: 14px; color: #a0aba6; font-size: .72rem; }
.pin-mark { color: #c5903e; font-size: .87rem; }
.empty-state { display: grid; justify-items: center; padding: 68px 20px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 55px; height: 55px; border-radius: 18px; color: var(--green); background: var(--green-soft); font-size: 1.55rem; }
.empty-state h2 { margin: 18px 0 7px; font: 700 1.24rem Manrope, sans-serif; letter-spacing: -.03em; }
.empty-state p { max-width: 390px; margin: 0 0 20px; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.workspace-message { min-height: 22px; margin: 15px 0; color: #63746c; font-size: .84rem; }
.note-dialog { width: min(430px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 18px; padding: 0; box-shadow: 0 22px 80px rgba(16,34,28,.22); }
.note-dialog::backdrop { background: rgba(25,37,33,.34); backdrop-filter: blur(3px); }
.dialog-bar { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 17px 20px; font-weight: 700; }
.new-note-form { padding: 20px; }
.new-note-form .button { margin-top: 13px; }
.editor-dialog { width: min(880px, calc(100% - 28px)); height: min(86vh, 780px); max-height: 86vh; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; padding: 0; background: #fff; box-shadow: 0 22px 80px rgba(16,34,28,.22); }
.editor-dialog::backdrop { background: rgba(25,37,33,.4); backdrop-filter: blur(3px); }
.editor-header { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding: 12px 19px; }
.editor-label { display: block; color: #97a39e; font-size: .65rem; font-weight: 700; letter-spacing: .14em; }
.save-state { display: block; margin-top: 4px; color: var(--green); font-size: .78rem; }
.save-state.saving { color: #a37a27; }
.save-state.error { color: #a94035; }
.editor-actions { display: flex; gap: 7px; }
.editor-actions .icon-button { width: 35px; height: 35px; }
.editor-actions .danger:hover { color: #a94035; border-color: #edc8c2; background: #fff6f4; }
.editor-fields { display: flex; height: calc(100% - 66px); flex-direction: column; padding: 22px 28px 14px; }
.editor-title { width: 100%; border: 0; outline: 0; color: var(--ink); font: 750 clamp(1.5rem, 3vw, 2.15rem)/1.2 Manrope, 'Segoe UI', sans-serif; letter-spacing: -.05em; }
.editor-title::placeholder { color: #b6c0bb; }
.editor-category { align-self: flex-start; margin: 14px 0 10px; border: 1px solid #e7ece9; border-radius: 8px; padding: 6px 9px; color: #5f756a; background: #f7faf8; font-size: .78rem; }
.editor-body { width: 100%; min-height: 180px; flex: 1; resize: none; border: 0; outline: 0; padding: 9px 0; color: #394743; background: transparent; font: 400 1rem/1.75 'DM Sans', 'Segoe UI', sans-serif; }
.editor-body::placeholder { color: #a6b0ac; }
.editor-foot { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid #edf0ee; padding-top: 11px; color: #98a39e; font-size: .72rem; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 224px minmax(0, 1fr); }
  .content-area { width: 92%; }
  .notes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 0 3vw; }
}
@media (max-width: 700px) {
  .workspace { display: block; }
  .sidebar { position: relative; display: block; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 13px 14px 10px; }
  .sidebar .brand-row { display: none; }
  .sidebar .new-note { display: none; }
  .nav-label, .sidebar-bottom { display: none; }
  .category-list { display: flex; gap: 5px; overflow-x: auto; padding: 0 0 1px; scrollbar-width: none; }
  .category-list::-webkit-scrollbar { display: none; }
  .category { flex: 0 0 auto; min-height: 37px; gap: 6px; padding: 0 10px; font-size: .79rem; white-space: nowrap; }
  .category .count, .nav-icon { display: none; }
  .topbar { position: relative; height: auto; flex-wrap: wrap; gap: 10px; padding: 13px 16px; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font: 700 1.05rem Manrope, sans-serif; }
  .mobile-brand .brand-mark { width: 30px; height: 30px; border-radius: 10px; font-size: .86rem; }
  .search-wrap { order: 3; width: 100%; }
  .top-new { margin-left: auto; min-height: 36px; padding: 0 11px; font-size: .83rem; }
  .mobile-logout { display: grid; width: 36px; height: 36px; font-size: 1.1rem; }
  #sign-out { display: none; }
  .content-area { width: auto; padding: 25px 16px 45px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 1.85rem; }
  .page-heading p.muted { font-size: .85rem; }
  .user-chip { display: none; }
  .privacy-banner { align-items: flex-start; font-size: .75rem; }
  .notes-grid { grid-template-columns: 1fr; gap: 10px; }
  .toolbar-actions { gap: 8px; }
  .toolbar-actions .sort-button { font-size: .72rem; }
  .note-card { min-height: 154px; }
  .note-actions { opacity: 1; }
  .editor-dialog { height: 92vh; max-height: 92vh; }
  .editor-fields { padding: 18px 18px 12px; }
  .editor-title { font-size: 1.55rem; }
  .editor-body { font-size: .96rem; }
  .editor-foot { font-size: .67rem; }
}
