/* Makryden Notes &mdash; brand: night #0E0A1A, deep #160F2B, gold #E8C266, dim #A79DC4 */
:root {
  --night: #0E0A1A;
  --deep: #160F2B;
  --deep-2: #1D1538;
  --gold: #E8C266;
  --gold-dim: #c9a554;
  --dim: #A79DC4;
  --text: #F2EDFB;
  --line: rgba(232, 194, 102, 0.14);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }
button { font-family: var(--sans); }
input, select, textarea { font-family: var(--sans); }

/* ---------- buttons / links ---------- */
.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--deep-2);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #241a08; }
.btn-gold:hover { background: #f2d189; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--dim);
  font-size: 18px;
  width: 40px; height: 40px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--deep-2); color: var(--text); }
.icon-btn.danger { color: #e08a8a; }
.icon-btn.avatar {
  background: var(--gold); color: #241a08; font-weight: 700;
  width: 36px; height: 36px; border-radius: 50%; font-size: 15px;
}
.link {
  background: none; border: none; color: var(--gold);
  font-size: 13px; cursor: pointer; padding: 4px 0; text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- auth ---------- */
#auth-screen {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #241a4d 0%, var(--night) 60%);
}
#auth-screen[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
}
.auth-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.auth-mark {
  width: 48px; height: 48px; border-radius: 14px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--gold), #9a7430);
  color: #241a08; font-family: var(--serif); font-weight: 700; font-size: 28px;
  display: flex; align-items: center; justify-content: center;
}
.auth-brand h1 { font-size: 26px; }
.auth-brand p { margin: 2px 0 0; color: var(--dim); font-size: 13px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; padding: 10px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--dim); font-weight: 600; cursor: pointer;
}
.auth-tab.active { background: var(--deep-2); color: var(--gold); border-color: var(--gold-dim); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.field input, #note-title, #search, #tag-input, #folder-select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--night); color: var(--text);
  font-size: 15px; outline: none;
}
.field input:focus, #search:focus, #tag-input:focus, #note-title:focus { border-color: var(--gold-dim); }
.auth-error {
  background: rgba(224, 90, 90, .12); border: 1px solid rgba(224, 90, 90, .4);
  color: #f0a8a8; border-radius: 10px; padding: 10px 12px; font-size: 13px;
}
.auth-links { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-top: 14px; }
.auth-note { color: var(--dim); font-size: 12px; margin: 18px 0 0; }

/* ---------- topbar ---------- */
#app { height: 100dvh; display: flex; flex-direction: column; }
#app[hidden] { display: none; }
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: var(--deep); position: relative; z-index: 30;
}
.topbar-title { font-family: var(--serif); font-size: 20px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.save-state { font-size: 12px; color: var(--dim); min-width: 64px; text-align: right; }
#back-btn { display: none; }
.account-menu {
  position: absolute; right: 12px; top: 60px;
  background: var(--deep-2); border: 1px solid var(--line); border-radius: var(--radius);
  min-width: 230px; padding: 8px; box-shadow: 0 18px 50px rgba(0,0,0,.5); z-index: 50;
}
.account-email { font-size: 13px; color: var(--dim); padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; word-break: break-all; }
.menu-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); padding: 10px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.menu-item:hover { background: var(--deep); }
.menu-item.danger { color: #e08a8a; }

/* ---------- layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }

/* sidebar */
#sidebar {
  width: 264px; flex: 0 0 auto;
  background: var(--deep); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 8px; }
.sidebar-head h2 { font-size: 19px; }
.folder-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; color: var(--dim);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; cursor: pointer; text-align: left;
}
.folder-item:hover { background: var(--deep-2); color: var(--text); }
.folder-item.active { background: var(--deep-2); color: var(--gold); }
.folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { font-size: 12px; opacity: .7; }
.folder-item .frow { display: flex; gap: 2px; }
.folder-item .frow button {
  background: none; border: none; color: var(--dim); cursor: pointer;
  font-size: 13px; padding: 2px 6px; border-radius: 6px;
}
.folder-item .frow button:hover { background: var(--night); color: var(--text); }
#sidebar-scrim { display: none; }
.sidebar-foot { margin-top: auto; padding: 10px 8px 0; font-size: 13px; color: var(--dim); }

/* list pane */
#list-pane {
  width: 360px; flex: 0 0 auto;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; background: var(--night);
}
.search-wrap { padding: 12px; }
#search { border-radius: 999px; }
.tag-filter-bar {
  margin: 0 12px 8px; padding: 8px 12px; font-size: 13px;
  background: var(--deep-2); border: 1px solid var(--line); border-radius: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.tag-filter-bar[hidden] { display: none; }
.note-list { flex: 1; overflow-y: auto; padding: 0 12px 24px; display: flex; flex-direction: column; gap: 8px; }
.note-row {
  background: var(--deep); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; text-align: left; width: 100%; color: var(--text);
  display: block;
}
.note-row:hover { border-color: var(--gold-dim); }
.note-row.active { border-color: var(--gold); }
.note-row-top { display: flex; align-items: flex-start; gap: 8px; }
.note-row-title { font-weight: 600; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-row-title.untitled { color: var(--dim); font-style: italic; font-weight: 400; }
.pin-toggle { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 16px; padding: 0 2px; }
.pin-toggle.on { color: var(--gold); }
.note-row-snippet { color: var(--dim); font-size: 13px; margin: 6px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-row-snippet mark, .note-row-title mark { background: rgba(232,194,102,.35); color: var(--text); border-radius: 3px; padding: 0 1px; }
.note-row-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.note-time { font-size: 12px; color: var(--dim); margin-left: auto; }
.tag-chip {
  display: inline-block; font-size: 12px; color: var(--gold);
  background: rgba(232,194,102,.1); border: 1px solid rgba(232,194,102,.25);
  border-radius: 999px; padding: 2px 10px; cursor: pointer;
}
.tag-chip:hover { background: rgba(232,194,102,.22); }
.empty { text-align: center; padding: 48px 24px; color: var(--dim); }
.empty-title { font-family: var(--serif); font-size: 24px; color: var(--text); margin: 0 0 8px; }

/* editor pane */
#editor-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--night); }
#editor-pane[hidden] { display: none; }
.editor-top { display: flex; gap: 8px; align-items: center; padding: 12px 16px 0; }
#note-title {
  flex: 1; border: none; background: transparent; font-family: var(--serif);
  font-size: 28px; font-weight: 700; color: var(--text); padding: 6px 2px; border-radius: 8px;
}
#note-title:focus { background: var(--deep); }
.editor-meta { display: flex; align-items: center; gap: 4px; }
#pin-btn.on { color: var(--gold); }
#folder-select { width: auto; max-width: 150px; padding: 8px 10px; font-size: 13px; }
.tag-editor { display: flex; align-items: center; gap: 8px; padding: 8px 16px; flex-wrap: wrap; }
.tag-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-chip.removable { padding-right: 6px; }
.tag-chip.removable button { background: none; border: none; color: var(--gold); cursor: pointer; font-size: 13px; padding: 0 0 0 4px; }
#tag-input { width: 160px; padding: 7px 10px; font-size: 13px; }
.toolbar {
  display: flex; gap: 2px; align-items: center; padding: 8px 16px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  overflow-x: auto; background: var(--deep); flex: 0 0 auto;
}
.toolbar button {
  background: none; border: none; color: var(--dim); font-size: 15px;
  min-width: 38px; height: 38px; border-radius: 8px; cursor: pointer; padding: 0 8px;
}
.toolbar button:hover { background: var(--deep-2); color: var(--text); }
.toolbar button.is-active { color: var(--gold); background: var(--deep-2); }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; flex: 0 0 auto; }
.editor { flex: 1; overflow-y: auto; padding: 18px 22px 40px; }
.tiptap { outline: none; min-height: 200px; font-size: 16px; line-height: 1.7; }
.tiptap p { margin: 0 0 12px; }
.tiptap h1 { font-size: 30px; margin: 20px 0 12px; }
.tiptap h2 { font-size: 24px; margin: 18px 0 10px; }
.tiptap ul, .tiptap ol { padding-left: 24px; margin: 0 0 12px; }
.tiptap blockquote { border-left: 3px solid var(--gold-dim); margin: 0 0 12px; padding: 4px 0 4px 14px; color: var(--dim); }
.tiptap code { background: var(--deep-2); padding: 2px 6px; border-radius: 6px; font-size: 14px; }

/* attachments */
.attachments { border-top: 1px solid var(--line); padding: 12px 16px 20px; background: var(--deep); flex: 0 0 auto; max-height: 220px; overflow-y: auto; }
.attachments-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.attachments-head h3 { font-size: 18px; }
.attachment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attachment-list li {
  display: flex; align-items: center; gap: 10px;
  background: var(--night); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.att-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.att-size { font-size: 12px; color: var(--dim); }
.att-dl, .att-del { background: none; border: none; cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 6px; color: var(--gold); }
.att-del { color: #e08a8a; }
.upload-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; color: var(--dim); }
.upload-progress[hidden] { display: none; }
.upload-bar { flex: 1; height: 8px; background: var(--night); border-radius: 999px; overflow: hidden; }
#upload-fill { height: 100%; width: 0%; background: var(--gold); border-radius: 999px; transition: width .15s; }

/* toasts */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast {
  background: var(--deep-2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.5);
  animation: toast-in .2s ease;
}
.toast.error { border-color: rgba(224,90,90,.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(8,5,18,.7); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--deep); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: 100%; max-width: 400px; }
.modal h2 { font-size: 22px; margin-bottom: 6px; }
.modal p { color: var(--dim); font-size: 14px; margin: 0 0 14px; }
.modal input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--night); color: var(--text); font-size: 15px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- responsive ---------- */
#menu-btn { display: none; }

@media (max-width: 1100px) {
  #sidebar { width: 220px; }
  #list-pane { width: 300px; }
}

@media (max-width: 760px) {
  #menu-btn { display: inline-flex; }
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-105%); transition: transform .2s ease;
    width: min(300px, 84vw); box-shadow: 20px 0 60px rgba(0,0,0,.5);
  }
  body.sidebar-open #sidebar { transform: none; }
  #sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(8,5,18,.6); z-index: 55; }
  #sidebar-scrim[hidden] { display: none; }
  #list-pane { width: 100%; border-right: none; }
  #editor-pane { position: fixed; inset: 0; top: 0; z-index: 40; background: var(--night); padding-top: 0; }
  body[data-view="list"] #editor-pane { display: none; }
  body[data-view="editor"] #list-pane { display: none; }
  body[data-view="editor"] #back-btn { display: inline-flex; }
  body[data-view="editor"] #menu-btn { display: none; }
  .topbar-title { font-size: 17px; }
  .save-state { display: none; }
  #note-title { font-size: 24px; }
  #folder-select { max-width: 110px; }
}

/* ---------- share / export menu ---------- */
.editor-top{position:relative}
.share-menu{
  position:absolute;top:100%;right:8px;z-index:60;min-width:220px;
  background:var(--card,#1d1440);border:1px solid var(--line,rgba(232,194,102,.25));
  border-radius:14px;padding:6px;box-shadow:0 12px 40px rgba(0,0,0,.5);
}
.share-menu button{
  display:block;width:100%;text-align:left;background:none;border:none;
  padding:10px 12px;border-radius:10px;font-size:14px;color:inherit;cursor:pointer;
}
.share-menu button:hover{background:rgba(232,194,102,.12)}

/* ---------- note print view ---------- */
#note-print-view{display:none}
@media print{
  body>*{display:none !important}
  body>#note-print-view{display:block !important}
  #note-print-view{
    display:block !important;max-width:7.5in;margin:0 auto;padding:.5in;
    font-family:Georgia,'Times New Roman',serif;font-size:12pt;
    line-height:1.65;color:#000;background:#fff;
  }
  #note-print-view .np-title{font-size:22pt;margin:0 0 16pt;text-align:center}
  #note-print-view .np-body h1{font-size:17pt;margin:14pt 0 6pt}
  #note-print-view .np-body h2{font-size:14pt;margin:12pt 0 6pt}
  #note-print-view .np-body p{margin:0 0 10pt}
  #note-print-view .np-body ul,#note-print-view .np-body ol{margin:6pt 0 10pt 24pt}
  #note-print-view .np-body blockquote{border-left:3pt solid #999;padding-left:12pt;margin:10pt 0;font-style:italic;color:#333}
  @page{margin:.75in}
}
