:root {
  --bg:#07111f;
  --bg-soft:#0d1a30;
  --surface:#ffffff;
  --surface-2:#f4f7fb;
  --surface-3:#e9eef8;
  --accent:#3b82f6;
  --accent-strong:#1d4ed8;
  --accent-soft:rgba(59,130,246,.12);
  --success:#16a34a;
  --danger:#ef4444;
  --warning:#f59e0b;
  --text-1:#0f172a;
  --text-2:#475569;
  --text-3:#94a3b8;
  --text-on-dark:#f8fafc;
  --border:rgba(15,23,42,.08);
  --border-strong:rgba(15,23,42,.14);
  --shadow-sm:0 10px 24px rgba(15,23,42,.06);
  --shadow-md:0 20px 48px rgba(15,23,42,.12);
  --shadow-lg:0 30px 80px rgba(2,6,23,.34);
  --radius-sm:12px;
  --radius-md:18px;
  --radius-lg:26px;
  --radius-xl:34px;
  --font:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html{height:100%;-webkit-text-size-adjust:100%}
body{
  min-height:100%;
  font-family:var(--font);
  color:var(--text-1);
  background:
    radial-gradient(circle at top left, rgba(59,130,246,.18), transparent 32%),
    radial-gradient(circle at bottom right, rgba(14,165,233,.14), transparent 28%),
    linear-gradient(180deg, #eef4ff 0%, #f8fbff 45%, #edf3fb 100%);
  overflow:hidden;
  touch-action:manipulation;
}
button,input,textarea,select{font:inherit}
.hidden{display:none!important}
.screen{position:fixed;inset:0;display:flex;flex-direction:column;transition:opacity .28s ease,transform .28s ease}
.screen.hidden{opacity:0;pointer-events:none;transform:scale(.985)}
code{font-family:'Consolas','SFMono-Regular',monospace}

#auth-screen{
  align-items:center;
  justify-content:center;
  background:
    radial-gradient(circle at 20% 20%, rgba(116,180,255,.22), transparent 24%),
    radial-gradient(circle at 78% 18%, rgba(59,130,246,.2), transparent 26%),
    linear-gradient(145deg, #081223 0%, #0f1c35 56%, #07111e 100%);
  overflow:auto;
  padding:28px 18px;
}
.auth-shell{width:100%;max-width:460px}
.auth-card{
  position:relative;
  overflow:hidden;
  border-radius:var(--radius-xl);
  padding:26px;
  background:linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.08));
  border:1px solid rgba(255,255,255,.14);
  box-shadow:var(--shadow-lg);
  backdrop-filter:blur(24px);
}
.auth-card::before{
  content:'';
  position:absolute;
  inset:auto -80px -110px auto;
  width:220px;
  height:220px;
  border-radius:50%;
  background:radial-gradient(circle, rgba(59,130,246,.28), transparent 70%);
}
.auth-badge{
  display:inline-flex;
  align-items:center;
  padding:8px 12px;
  margin-bottom:18px;
  border-radius:999px;
  background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.12);
  color:rgba(248,250,252,.8);
  font-size:12px;
  font-weight:600;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.auth-brand{display:flex;gap:16px;align-items:flex-start;margin-bottom:22px}
.auth-logo{
  width:72px;
  height:72px;
  flex-shrink:0;
  border-radius:22px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.05));
  border:1px solid rgba(255,255,255,.14);
  box-shadow:0 18px 40px rgba(2,6,23,.25);
}
.auth-logo svg{width:46px;height:46px}
.auth-kicker{
  color:rgba(226,232,240,.7);
  font-size:12px;
  font-weight:700;
  letter-spacing:.16em;
  text-transform:uppercase;
  margin-bottom:6px;
}
.auth-title{
  color:var(--text-on-dark);
  font-size:32px;
  line-height:1.05;
  letter-spacing:-.04em;
  margin-bottom:8px;
}
.auth-subtitle{color:rgba(226,232,240,.82);font-size:15px;line-height:1.6}
.auth-form{display:flex;flex-direction:column;gap:10px}
.field-label{color:rgba(226,232,240,.88);font-size:13px;font-weight:600;margin-top:4px}
.auth-input,.search-wrap input,.editor-nav-title,.modal-input{font-size:16px}
.auth-input{
  width:100%;
  padding:15px 16px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.08);
  color:var(--text-on-dark);
  outline:none;
  transition:border-color .16s ease,background .16s ease,box-shadow .16s ease;
}
.auth-input::placeholder{color:rgba(226,232,240,.5)}
.auth-input:focus{
  border-color:rgba(147,197,253,.88);
  background:rgba(255,255,255,.12);
  box-shadow:0 0 0 4px rgba(59,130,246,.16);
}
.primary-btn{
  border:none;
  border-radius:16px;
  padding:15px 18px;
  margin-top:8px;
  cursor:pointer;
  background:linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
  color:#fff;
  font-size:15px;
  font-weight:700;
  box-shadow:0 20px 36px rgba(37,99,235,.32);
  transition:transform .14s ease,box-shadow .14s ease,opacity .14s ease;
}
.primary-btn:active{transform:scale(.985)}
.primary-btn[disabled]{opacity:.72;cursor:wait}
.auth-message{min-height:22px;margin-top:14px;color:#fecaca;font-size:14px;line-height:1.45}
.auth-message.is-success{color:#bbf7d0}
.auth-help{margin-top:18px;display:grid;gap:10px}
.auth-help-item{
  padding:12px 14px;
  border-radius:16px;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.1);
  color:rgba(226,232,240,.88);
  font-size:13px;
  line-height:1.55;
}
.auth-help-item code{color:#dbeafe}

#list-screen{background:transparent}
.list-shell{flex:1;display:flex;flex-direction:column;padding:18px;gap:14px;overflow:hidden}
.list-hero{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  padding:26px;
  border-radius:30px;
  background:linear-gradient(135deg, #0f1d35 0%, #162949 55%, #0b1830 100%);
  color:#fff;
  box-shadow:var(--shadow-md);
}
.list-nav-title{font-size:32px;line-height:1.04;letter-spacing:-.05em;font-weight:800;margin-bottom:8px}
.list-nav-subtitle{color:rgba(226,232,240,.76);font-size:14px;line-height:1.55;max-width:340px}
.list-nav-actions,.editor-nav-actions{display:flex;align-items:center;gap:8px}
.icon-btn{
  width:42px;
  height:42px;
  flex-shrink:0;
  border:none;
  border-radius:14px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  color:var(--accent);
  background:rgba(255,255,255,.92);
  box-shadow:var(--shadow-sm);
  transition:transform .14s ease,background .14s ease,color .14s ease;
}
.icon-btn svg{width:18px;height:18px}
.icon-btn:active{transform:scale(.96)}
.icon-btn.danger{color:var(--danger)}
.icon-btn.subtle{color:var(--text-1);font-size:18px}
.list-summary{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.summary-card{
  padding:18px 20px;
  border-radius:22px;
  background:rgba(255,255,255,.88);
  border:1px solid rgba(255,255,255,.82);
  box-shadow:var(--shadow-sm);
}
.summary-label{
  display:block;
  color:var(--text-2);
  font-size:12px;
  font-weight:700;
  letter-spacing:.08em;
  text-transform:uppercase;
  margin-bottom:10px;
}
.summary-value{color:var(--text-1);font-size:22px;letter-spacing:-.04em}
.list-search{padding:4px 0}
.search-wrap{
  display:flex;
  align-items:center;
  gap:10px;
  padding:16px 18px;
  border-radius:20px;
  background:rgba(255,255,255,.9);
  border:1px solid rgba(255,255,255,.92);
  box-shadow:var(--shadow-sm);
}
.search-wrap svg{color:var(--text-3);flex-shrink:0}
.search-wrap input{flex:1;border:none;background:transparent;color:var(--text-1);outline:none}
.search-wrap input::placeholder{color:var(--text-3)}
.notes-list{flex:1;overflow:auto;display:flex;flex-direction:column;gap:12px;padding-bottom:94px}
.note-card{
  display:flex;
  gap:14px;
  align-items:flex-start;
  position:relative;
  overflow:hidden;
  padding:18px;
  border-radius:24px;
  background:rgba(255,255,255,.92);
  border:1px solid rgba(255,255,255,.84);
  box-shadow:var(--shadow-sm);
  cursor:pointer;
  transition:transform .16s ease,box-shadow .16s ease;
  animation:fadeUp .22s ease both;
}
.note-card::before{
  content:'';
  position:absolute;
  inset:0 auto 0 0;
  width:4px;
  background:linear-gradient(180deg, #60a5fa, #2563eb);
  opacity:0;
  transition:opacity .16s ease;
}
.note-card:hover::before{opacity:1}
.note-card:active{transform:scale(.992)}
.note-card-emoji{
  width:46px;
  height:46px;
  flex-shrink:0;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:16px;
  background:var(--accent-soft);
  font-size:24px;
}
.note-card-body{flex:1;min-width:0}
.note-card-title{font-size:16px;font-weight:700;line-height:1.35;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:6px}
.note-card-preview{color:var(--text-2);font-size:14px;line-height:1.55;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.note-card-meta{display:flex;align-items:center;gap:8px;margin-top:10px}
.note-card-date,.note-card-badge{
  display:inline-flex;
  align-items:center;
  padding:5px 9px;
  border-radius:999px;
  font-size:11px;
  font-weight:700;
}
.note-card-date{color:var(--text-2);background:var(--surface-2)}
.note-card-badge{color:var(--accent-strong);background:var(--accent-soft)}
.note-thumb{width:60px;height:60px;flex-shrink:0;border-radius:16px;object-fit:cover;border:1px solid rgba(15,23,42,.06)}
.empty-state{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:42px 18px;text-align:center;color:var(--text-3)}
.empty-state svg{opacity:.36}
.empty-state p{max-width:260px;font-size:15px;line-height:1.6}
.status-count{text-align:center;color:var(--text-3);font-size:12px}
.fab{
  position:fixed;
  right:24px;
  bottom:26px;
  width:60px;
  height:60px;
  border:none;
  border-radius:22px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  color:#fff;
  font-size:34px;
  background:linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
  box-shadow:0 24px 42px rgba(37,99,235,.34);
}
.fab:active{transform:scale(.97)}

#editor-screen{background:rgba(248,250,252,.98)}
.editor-nav{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  gap:10px;
  padding:16px 18px 14px;
  background:rgba(248,250,252,.92);
  backdrop-filter:blur(22px);
  border-bottom:1px solid var(--border);
}
.editor-nav-back{display:flex;align-items:center;gap:4px;border:none;background:none;color:var(--accent);cursor:pointer;font-size:15px;font-weight:600}
.editor-nav-back svg{width:9px;height:15px}
.editor-nav-title{flex:1;min-width:0;border:none;background:transparent;text-align:center;color:var(--text-1);font-weight:700;outline:none}
.editor-save-pill{
  display:inline-flex;
  align-items:center;
  padding:8px 10px;
  border-radius:999px;
  font-size:11px;
  font-weight:700;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.editor-save-pill.is-idle,.editor-save-pill.is-saved{background:rgba(22,163,74,.12);color:var(--success)}
.editor-save-pill.is-saving{background:rgba(245,158,11,.16);color:#b45309}
.editor-save-pill.is-error{background:rgba(239,68,68,.12);color:var(--danger)}
.editor-toolbar{
  display:flex;
  align-items:center;
  gap:1px;
  flex-wrap:wrap;
  overflow:auto;
  padding:8px 10px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,.88);
  backdrop-filter:blur(20px);
  scrollbar-width:none;
}
.editor-toolbar::-webkit-scrollbar{display:none}
.tb-sep{width:1px;height:22px;margin:0 4px;background:var(--border-strong)}
.tb-btn{
  border:none;
  border-radius:10px;
  padding:7px 9px;
  background:none;
  color:var(--text-1);
  cursor:pointer;
  font-size:12px;
  font-weight:700;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:background .14s ease,color .14s ease;
}
.tb-btn svg{width:16px;height:16px}
.tb-btn:hover{background:var(--accent-soft);color:var(--accent-strong)}
.tb-btn:active,.tb-btn.active{background:var(--accent);color:#fff}
.tb-btn:disabled{opacity:.35}
.editor-scroll{flex:1;overflow:auto;position:relative}
.editor-content{
  min-height:100%;
  padding:24px 20px 140px;
  color:var(--text-1);
  font-size:16px;
  line-height:1.72;
  outline:none;
  caret-color:var(--accent);
  position:relative;
}
.editor-content:empty::before{content:attr(data-placeholder);color:var(--text-3);pointer-events:none}
.editor-content h1{font-size:28px;margin:14px 0 8px;line-height:1.14}
.editor-content h2{font-size:22px;margin:12px 0 6px;line-height:1.18}
.editor-content h3{font-size:18px;margin:10px 0 6px}
.editor-content p{margin:4px 0}
.editor-content blockquote{margin:12px 0;padding-left:14px;border-left:3px solid var(--accent);color:var(--text-2);font-style:italic}
.editor-content ul,.editor-content ol{padding-left:24px;margin:8px 0}
.editor-content a{color:var(--accent-strong);text-decoration:none}
.editor-content a:hover{text-decoration:underline}
.editor-content code{background:var(--surface-3);border-radius:8px;padding:2px 6px;font-size:13px}
.drop-overlay{
  position:absolute;
  inset:10px;
  z-index:30;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;
  border:2px dashed var(--accent);
  border-radius:26px;
  background:rgba(59,130,246,.08);
  color:var(--accent-strong);
  opacity:0;
  pointer-events:none;
  transition:opacity .16s ease;
}
.drop-overlay.active{opacity:1}
.drop-overlay-icon{
  width:56px;
  height:56px;
  border-radius:18px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#fff;
  font-size:28px;
  box-shadow:var(--shadow-sm);
}
.drop-overlay-text{font-size:16px;font-weight:700}
.drop-overlay-sub{color:var(--text-2);font-size:13px}

.media-wrapper{
  position:relative;
  display:inline-block;
  vertical-align:top;
  margin:10px 0;
  border-radius:16px;
  user-select:none;
  outline:2px solid transparent;
  outline-offset:3px;
  transition:outline-color .15s ease,box-shadow .15s ease;
}
.media-wrapper.selected{outline-color:var(--accent);box-shadow:0 0 0 6px rgba(59,130,246,.12)}
.media-wrapper.floating{position:absolute;z-index:30;margin:0;cursor:move;box-shadow:var(--shadow-md)}
.media-wrapper.floating.is-dragging{opacity:.9}
.media-wrapper>img,.media-wrapper>video,.media-wrapper>iframe{display:block;width:100%;height:auto;border:none;border-radius:16px;background:#000}
.media-wrapper>iframe{height:0}
.resize-handle{
  position:absolute;
  right:8px;
  bottom:8px;
  width:20px;
  height:20px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:7px;
  background:rgba(37,99,235,.95);
  color:#fff;
  box-shadow:0 8px 18px rgba(15,23,42,.24);
  opacity:0;
  cursor:se-resize;
}
.media-wrapper.selected .resize-handle{opacity:1}
.resize-handle svg{width:10px;height:10px;pointer-events:none}

.ctx-menu{
  position:fixed;
  z-index:2000;
  min-width:200px;
  padding:6px;
  border-radius:18px;
  background:rgba(15,23,42,.96);
  color:#fff;
  border:1px solid rgba(255,255,255,.08);
  box-shadow:0 28px 60px rgba(2,6,23,.42);
}
.ctx-item{
  width:100%;
  border:none;
  background:none;
  color:inherit;
  display:flex;
  align-items:center;
  gap:10px;
  padding:11px 12px;
  border-radius:12px;
  text-align:left;
  cursor:pointer;
  font-size:14px;
  font-weight:600;
}
.ctx-item svg{width:16px;height:16px;opacity:.8}
.ctx-item:hover{background:rgba(255,255,255,.1)}
.ctx-item.is-active{color:#86efac}
.ctx-item.danger{color:#fca5a5}
.ctx-item.danger:hover{background:rgba(239,68,68,.18)}
.ctx-sep{height:1px;margin:4px 0;background:rgba(255,255,255,.08)}

.link-embed{
  display:flex;
  align-items:center;
  gap:12px;
  margin:8px 0;
  padding:13px 14px;
  border-radius:16px;
  background:var(--surface-2);
  border:1px solid var(--border);
  text-decoration:none!important;
}
.link-embed:hover{background:var(--accent-soft)}
.link-embed-icon{
  width:36px;
  height:36px;
  flex-shrink:0;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  color:var(--accent-strong);
  background:rgba(59,130,246,.14);
}
.link-embed-title{font-size:13px;font-weight:700;color:var(--text-1)}
.link-embed-url{font-size:11px;color:var(--text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.modal-overlay{
  position:fixed;
  inset:0;
  z-index:200;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  padding-top:24px;
  background:rgba(2,6,23,.36);
  backdrop-filter:blur(8px);
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease;
}
.modal-overlay.open{opacity:1;pointer-events:auto}
.modal-sheet{
  width:100%;
  max-width:620px;
  max-height:84vh;
  overflow:auto;
  border-radius:30px 30px 0 0;
  background:#fff;
  padding:22px 22px 40px;
  transform:translateY(100%);
  transition:transform .24s ease;
}
.modal-overlay.open .modal-sheet{transform:translateY(0)}
.modal-handle{width:36px;height:4px;margin:0 auto 18px;border-radius:999px;background:#cbd5e1}
.modal-title{font-size:18px;font-weight:800;margin-bottom:16px}
.modal-input{
  width:100%;
  padding:13px 14px;
  border-radius:14px;
  border:1px solid var(--border-strong);
  background:var(--surface-2);
  color:var(--text-1);
  outline:none;
  margin-bottom:10px;
}
.modal-input:focus{border-color:var(--accent);box-shadow:0 0 0 4px rgba(59,130,246,.14)}
.modal-inline-check{display:flex;align-items:center;gap:8px;color:var(--text-2);font-size:14px;margin:2px 0 14px}
.modal-inline-check input{width:16px;height:16px;accent-color:var(--accent)}
.modal-btn{
  width:100%;
  border:none;
  border-radius:14px;
  padding:14px 16px;
  cursor:pointer;
  font-size:15px;
  font-weight:700;
  margin-bottom:8px;
}
.modal-btn-primary{color:#fff;background:linear-gradient(135deg, #60a5fa 0%, #2563eb 100%)}
.modal-btn-secondary{color:var(--text-2);background:var(--surface-2)}
.modal-separator,.modal-hint,.sheet-caption{color:var(--text-3);text-align:center}
.modal-hint{font-size:12px;line-height:1.5;margin:-2px 0 10px}
.modal-separator{font-size:12px;font-weight:700;text-transform:uppercase;margin:2px 0 10px}
.upload-label{display:block}
.upload-trigger{text-align:center}
.action-sheet{padding:0}
.action-btn{
  width:100%;
  border:none;
  background:none;
  display:flex;
  align-items:center;
  gap:12px;
  padding:15px 18px;
  cursor:pointer;
  text-align:left;
  color:var(--text-1);
  font-size:15px;
}
.action-btn:hover{background:var(--surface-2)}
.action-btn svg{width:20px;height:20px;color:var(--accent);flex-shrink:0}
.action-btn.danger{color:var(--danger)}
.action-btn.danger svg{color:var(--danger)}
.action-btn-sep{height:1px;margin:3px 0;background:var(--border)}
.action-sheet-footer{padding:10px 18px 18px}
.sheet-caption{font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;padding:4px 18px 8px}
.emoji-grid{display:grid;grid-template-columns:repeat(8,1fr);gap:6px;margin-bottom:14px}
.emoji-opt{display:flex;align-items:center;justify-content:center;padding:8px;border-radius:12px;border:2px solid transparent;cursor:pointer;font-size:22px}
.emoji-opt:hover{background:var(--accent-soft)}
.emoji-opt.selected{border-color:var(--accent);background:var(--accent-soft)}

@keyframes fadeUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-thumb{background:rgba(15,23,42,.18);border-radius:999px}
@media (max-width:720px){
  .list-shell{padding:14px}
  .list-hero,.summary-card,.note-card{border-radius:22px}
  .list-nav-title{font-size:28px}
}
@media (max-width:560px){
  .auth-card{padding:22px;border-radius:28px}
  .auth-brand{flex-direction:column}
  .auth-title{font-size:28px}
  .list-summary{grid-template-columns:1fr}
  .list-hero{padding:22px}
  .list-nav-actions{flex-direction:column}
  .editor-nav{padding-left:12px;padding-right:12px}
  .editor-save-pill{display:none}
  .editor-nav-title{text-align:left}
  .emoji-grid{grid-template-columns:repeat(6,1fr)}
}
