/* ============ Tutum Nube Web — design system ============ */

:root {
  --bg: #f3f5fa;
  --bg-soft: #ffffff;
  --bg-panel: #ffffff;
  --text: #1a2032;
  --text-soft: #5a6478;
  --muted: #8b93a7;
  --border: #e2e6f0;
  --primary: #4f7cff;
  --primary-2: #7a5cff;
  --grad: linear-gradient(135deg, #4f7cff, #7a5cff);
  --danger: #e5484d;
  --ok: #30a46c;
  --warn: #f5a524;
  --shadow: 0 8px 30px rgba(28, 38, 66, .10);
  --shadow-lg: 0 18px 60px rgba(28, 38, 66, .16);
  --radius: 14px;
  --sidebar-w: 320px;
}

[data-theme="dark"] {
  --bg: #0c101b;
  --bg-soft: #121829;
  --bg-panel: #121829;
  --text: #e8ecf6;
  --text-soft: #aab3c8;
  --muted: #6d7789;
  --border: #232b40;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background .35s ease, color .35s ease;
}

#app { min-height: 100%; }

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

a { color: var(--primary); text-decoration: none; }

::selection { background: rgba(79, 124, 255, .3); }

/* ---------- boot splash ---------- */
.boot-splash {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
}
.boot-logo { animation: floaty 3s ease-in-out infinite; }
.boot-title { font-size: 22px; font-weight: 700; letter-spacing: .3px; margin-top: 10px; }
.boot-title span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.boot-sub { color: var(--muted); font-size: 13px; }
.boot-bar { width: 180px; height: 4px; border-radius: 4px; margin-top: 18px; background: var(--border); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 40%; background: var(--grad); border-radius: 4px; animation: slide 1.1s ease-in-out infinite; }

@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- auth screens ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(1200px 600px at 15% -10%, rgba(79,124,255,.14), transparent 60%),
    radial-gradient(1000px 500px at 110% 110%, rgba(122,92,255,.12), transparent 60%);
}
.auth-card {
  width: 100%; max-width: 430px; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 34px 30px; box-shadow: var(--shadow-lg);
  animation: rise .45s cubic-bezier(.2,.8,.2,1);
}
.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo h1 { font-size: 21px; margin: 10px 0 2px; font-weight: 700; }
.auth-logo p { margin: 0; color: var(--muted); font-size: 13.5px; }
.auth-card h2 { font-size: 16.5px; margin: 0 0 4px; }
.auth-card .hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; font-weight: 600; }
.input, textarea.input {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  border: 1.5px solid var(--border); background: var(--bg);
  outline: none; transition: border .2s, box-shadow .2s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,124,255,.15); }
.input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1px; }
textarea.input { min-height: 170px; resize: vertical; }

.pw-meter { height: 5px; border-radius: 5px; background: var(--border); overflow: hidden; margin-top: 6px; }
.pw-meter i { display: block; height: 100%; width: 0; transition: width .3s, background .3s; }
.pw-meter-note { font-size: 12px; color: var(--muted); margin-top: 4px; min-height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8.6px 18px; border-radius: 12px; border: none; cursor: pointer;
  font-weight: 600; font-size: 14.5px;
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(79,124,255,.35); }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(79,124,255,.45); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.busy { pointer-events: none; }
.btn-ghost { background: transparent; color: var(--text-soft); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(229, 72, 77, .12); color: var(--danger); border: 1.5px solid rgba(229,72,77,.35); }
.btn-block { width: 100%; margin-top: 6px; }
.btn-sm { padding: 5.4px 12px; font-size: 13px; border-radius: 9px; }

.auth-alt { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--muted); }
.auth-alt button { background: none; border: none; color: var(--primary); cursor: pointer; font-weight: 600; padding: 4px; }

.notice {
  padding: 11px 13px; border-radius: 11px; font-size: 13.5px; margin: 4px 0 14px;
  display: flex; gap: 9px; align-items: flex-start;
  animation: rise .3s ease;
}
.notice svg { flex-shrink: 0; margin-top: 1px; }
.notice.err { background: rgba(229,72,77,.12); color: var(--danger); }
.notice.ok { background: rgba(48,164,108,.12); color: var(--ok); }
.notice.info { background: rgba(79,124,255,.12); color: var(--primary); }
.notice.warn { background: rgba(245,165,36,.14); color: var(--warn); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* onboarding steps */
.step-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.step-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: background .3s, width .3s; }
.step-dots i.on { width: 22px; border-radius: 6px; background: var(--grad); }

.unlock-code-box {
  background: var(--bg); border: 1.5px dashed var(--border); border-radius: 13px;
  padding: 16px; margin: 12px 0;
}
.unlock-code-box code {
  display: block; word-break: break-all; font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px; line-height: 1.7; color: var(--text); user-select: all;
}
.unlock-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.checkline { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; cursor: pointer; }
.checkline input { margin-top: 3px; accent-color: var(--primary); }

.qr-area { display: flex; justify-content: center; margin: 14px 0; }
.qr-area canvas { border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.secret-reveal { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }

/* plan cards */
.plans { display: grid; gap: 12px; margin: 8px 0 4px; }
.plan {
  border: 1.5px solid var(--border); border-radius: 15px; padding: 15px 16px;
  cursor: pointer; transition: border .2s, transform .2s, box-shadow .2s;
  position: relative; background: var(--bg);
}
.plan:hover { transform: translateY(-2px); }
.plan.sel { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,124,255,.14); }
.plan .p-name { font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.plan .p-price { font-size: 19px; font-weight: 700; }
.plan .p-price small { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.plan .p-note { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.plan .badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: rgba(48,164,108,.15); color: var(--ok); font-weight: 700; }

.providers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.provider {
  border: 1.5px solid var(--border); border-radius: 13px; padding: 13px;
  display: flex; flex-direction: column; gap: 7px; align-items: center;
  cursor: pointer; transition: border .2s, transform .2s; background: var(--bg); font-weight: 600;
}
.provider:hover { transform: translateY(-2px); }
.provider.sel { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,124,255,.14); }
.provider small { color: var(--muted); font-weight: 500; }

/* ---------- main app ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border); background: var(--bg-soft);
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; height: 100dvh; z-index: 30;
}
.brand {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px 18px 10px;
  font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.brand span.tw { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.search-box { padding: 14px 22px 0; max-width: 944px; width: 100%; margin: 0 auto; display: flex; align-items: center; gap: 8px; }
.search-box .search-icon { display: inline-flex; align-items: center; color: var(--muted); flex-shrink: 0; }
.search-box .input { flex: 1; min-width: 0; background: var(--bg); }
.search-clear { flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-soft); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: all .18s; }
.search-clear:hover { border-color: var(--danger); color: var(--danger); transform: translateY(-1px); }
.search-clear:active { transform: scale(.92); }
.search-clear[hidden] { display: none; }

.cat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 10px; }
.cat-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 11px; cursor: pointer; color: var(--text-soft);
  transition: background .18s, color .18s; margin-bottom: 2px; position: relative;
}
.cat-item:hover { background: var(--bg); color: var(--text); }
.cat-item.active { background: var(--bg); color: var(--primary); font-weight: 600; }
.cat-item.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 3px; background: var(--grad);
}
.cat-item .ci-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item .ci-count { font-size: 11.5px; color: var(--muted); background: var(--bg); padding: 2px 7px; border-radius: 10px; }
.cat-item { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.cat-item .ci-edit { display: none; border: 0; background: none; padding: 4px; cursor: pointer; color: var(--muted); line-height: 0; touch-action: manipulation; }
.cat-item:hover .ci-edit, .cat-item.active .ci-edit { display: inline-flex; }
@media (hover: none) { .cat-item .ci-edit { display: inline-flex; } }
.cat-item .ci-edit:hover { color: var(--primary); }

.side-foot { border-top: 1px solid var(--border); padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar > .user-chip { padding: 0 18px 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--grad);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.user-chip .u-meta { overflow: hidden; }
.user-chip .u-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .u-plan { font-size: 11.5px; color: var(--muted); }
.side-foot .row { display: flex; gap: 8px; }
.side-foot .row .btn { flex: 1; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
  color: var(--muted); padding: 4px 10px; background: var(--bg);
  border-radius: 20px; border: 1px solid var(--border);
}
.sync-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sync-pill.offline .dot { background: var(--warn); }
.sync-pill.syncing .dot { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 22px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--bg); z-index: 20; backdrop-filter: blur(8px);
}
.topbar h2 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; border: 1.5px solid var(--border);
  background: var(--bg-soft); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-soft); transition: all .18s; flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.content { flex: 1; padding: 22px; max-width: 900px; width: 100%; margin: 0 auto; }

.entries-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.entries-list { display: flex; flex-direction: column; gap: 8px; }
.entry-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; cursor: pointer; transition: border-color .15s ease, transform .15s ease;
}
.entry-row:hover { border-color: rgba(79,124,255,.5); transform: translateX(3px); }
.entry-row .er-ico { color: var(--primary); display: inline-flex; }
.entry-row .er-title { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-row .er-img { color: var(--muted); display: inline-flex; }
.entry-row .er-cat {  display: inline-flex; align-items: center; gap: 5px;  color: var(--primary); background: rgba(79,124,255,.1);  font-size: 12px; padding: 3px 9px; border-radius: 10px; white-space: nowrap; }
.entry-row .er-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ev-cat {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(79,124,255,.12); color: var(--primary);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
  margin: 0 0 10px; width: fit-content;
}
.entry-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; cursor: pointer; transition: transform .18s, box-shadow .18s, border-color .18s;
  display: flex; flex-direction: column; gap: 8px; position: relative;
  animation: rise .35s ease both;
}
.entry-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: rgba(79,124,255,.5); }
.entry-card .e-title { font-weight: 650; font-size: 14.5px; display: flex; gap: 8px; align-items: center; }
.entry-card .e-title .ico { color: var(--primary); }
.entry-card .e-preview {
  color: var(--text-soft); font-size: 13px; line-height: 1.55; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  white-space: pre-wrap; word-break: break-word;
}
.entry-card .e-thumbs { display: flex; gap: 6px; }
.entry-card .e-thumbs img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.entry-card .e-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: auto; }

.spinner { width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .big { font-size: 42px; margin-bottom: 10px; }
.empty-state h3 { color: var(--text); margin: 0 0 6px; font-size: 17px; }
.empty-state p { margin: 0 0 18px; font-size: 13.5px; }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(8, 11, 20, .55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 18px; backdrop-filter: blur(4px); animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  position: relative;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 18px;
  width: 100%; max-width: 520px; max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  padding: 24px; box-shadow: var(--shadow-lg); animation: rise .28s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column;
}
.modal.wide { max-width: 760px; }
.modal > h3 { flex-shrink: 0; }
.modal-x {  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;  border: none; border-radius: 9px; background: transparent;  color: var(--muted); cursor: pointer; display: inline-flex;  align-items: center; justify-content: center; transition: background .15s, color .15s;  z-index: 2;
}
.modal-x:hover { background: var(--bg); color: var(--text); }
.modal h3 { margin: 0 0 4px; font-size: 17px; display: flex; align-items: center; gap: 9px; padding-right: 34px; }
.modal .m-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-shrink: 0; }
/* dialog body grows between pinned header and actions */
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(99px, 1fr)); gap: 10px; margin: 12px 0; }
.attach-tile { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 1; }
.attach-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-tile .rm {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px;
  background: rgba(10, 12, 20, .65); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.attach-add {
  aspect-ratio: 1; border: 1.5px dashed var(--border); border-radius: 12px;
  display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer; font-size: 12px; background: none; transition: all .18s;
}
.attach-add:hover { border-color: var(--primary); color: var(--primary); }

.entry-view .ev-body {
  word-break: break-word; font-size: 14.5px; line-height: 1.65;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}
.entry-view .ev-body p { margin: 0 0 .6em; }
.entry-view .ev-body p:last-child { margin-bottom: 0; }
.entry-view .ev-body ul, .entry-view .ev-body ol { margin: .4em 0 .8em; padding-left: 1.5em; }
.entry-view .ev-body li { margin: .15em 0; }
.entry-view .ev-body h1, .entry-view .ev-body h2, .entry-view .ev-body h3, .entry-view .ev-body h4 { margin: .9em 0 .35em; line-height: 1.25; font-weight: 700; }
.entry-view .ev-body h1 { font-size: 1.45em; }
.entry-view .ev-body h2 { font-size: 1.28em; }
.entry-view .ev-body h3 { font-size: 1.14em; }
.entry-view .ev-body h4 { font-size: 1.02em; }
.entry-view .ev-body h1:first-child, .entry-view .ev-body h2:first-child, .entry-view .ev-body h3:first-child, .entry-view .ev-body h4:first-child { margin-top: 0; }
.fmt-btn.fmt-txt { width: auto; padding: 0 7px; font-size: 11.5px; font-weight: 600; }
.entry-view .ev-images { display: grid; gap: 12px; margin-top: 14px; }
.entry-view .ev-images img { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); }

.settings-list { display: flex; flex-direction: column; gap: 12px; }
.settings-group { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.settings-group-label {
  color: var(--muted); font-size: 11.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; padding: 0 2px; margin-top: 6px;
}
.settings-group .setting-row { gap: 10px; padding: 12px 14px; }
.acct-version { text-align: center; color: var(--muted); font-size: 11.5px; padding-top: 6px; }
.setting-row {
  display: flex; align-items: center; gap: 13px; padding: 15px 16px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--bg);
}
.setting-row .s-ico {
  width: 38px; height: 38px; border-radius: 11px; background: rgba(79,124,255,.13);
  color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.setting-row .s-body { flex: 1; }
.setting-row .s-title { font-weight: 600; font-size: 14px; }
.setting-row .s-desc { color: var(--muted); font-size: 12.5px; }

.import-area textarea { min-height: 180px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

.toast-zone { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--bg-panel); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 12px; font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: rise .25s ease; display: flex; gap: 9px; align-items: center; max-width: 90vw;
}
.toast.err { border-color: rgba(229,72,77,.5); }
.toast.ok svg { color: var(--ok); }
.toast.err svg { color: var(--danger); }

.tier-banner {
  display: flex; gap: 12px; align-items: center; padding: 13px 16px; margin-bottom: 16px;
  background: rgba(79,124,255,.1); border: 1px solid rgba(79,124,255,.35); border-radius: 14px;
  font-size: 13.5px;
}
.tier-banner svg { color: var(--primary); flex-shrink: 0; }
.tier-banner .t-body { flex: 1; }

.limit-badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }

.hamburger { display: none; }
.backdrop { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  /* dialogs use the full usable viewport (safe areas respected) */
  .modal-back {
    align-items: stretch;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .modal { width: 100%; max-width: 100%; max-height: none; height: 100%; border-radius: 14px; padding: 18px; }
  .modal-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
  .modal-body .entry-editor { flex: 1; display: flex; flex-direction: column; }
  .field-grow { flex: 1; display: flex; flex-direction: column; }
  .field-grow textarea.input { flex: 1; min-height: 130px; }
  .modal-body .attach-grid { flex-shrink: 0; }
  .modal-actions { margin-top: 12px; }

  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: min(84vw, 320px);
    height: 100vh; height: 100dvh;
    transform: translateX(-102%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .backdrop { display: block; position: fixed; inset: 0; background: rgba(8,11,20,.5); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .3s; }
  .backdrop.show { opacity: 1; pointer-events: auto; }
  .hamburger { display: inline-flex; }
  .content { padding: 16px; padding-top: 14px; }
  .search-box { padding: 10px 16px 0; }
  .entries-grid { grid-template-columns: 1fr; }
  .topbar { padding: 12px 14px; }
  .auth-card { padding: 26px 20px; }
  .providers { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- admin dialog ---------- */
.admin-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
  background: var(--bg-soft);
  animation: rise .25s ease;
}

/* ---------- rich text editor & formatted view ---------- */

.fmt-toolbar {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.fmt-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 28px; border: none; border-radius: 7px;
  background: none; color: var(--text-soft); cursor: pointer;
  transition: background .18s, color .18s, transform .12s;
}
.fmt-btn:hover { background: rgba(79,124,255,.12); color: var(--primary); }
.fmt-btn:active { transform: scale(.94); }
.fmt-btn.on { background: var(--primary); color: #fff; }
.fmt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }

.rich-editor { min-height: 170px; max-height: 45vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word; line-height: 1.6; resize: vertical; font: inherit; color: inherit; }
.rich-editor::placeholder { color: var(--muted); }
.rich-editor:empty::before { content: attr(placeholder); color: var(--muted); pointer-events: none; }
.rich-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,124,255,.15); }

.ev-body a, .e-preview a, .rich-editor a {
  color: var(--primary); text-decoration: underline; text-underline-offset: 2px;
  transition: opacity .18s;
}
.ev-body a:hover, .rich-editor a:hover { opacity: .8; }

/* ---------- auto-logout slider ---------- */

.idle-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.idle-endpoint { font-size: 11.5px; color: var(--muted); }
.idle-value { font-size: 12.5px; font-weight: 600; color: var(--text-soft); min-width: 70px; text-align: right; }
.idle-range { flex: 1; min-width: 120px; accent-color: var(--primary); cursor: pointer; transition: opacity .18s; }
.idle-range:active { opacity: .8; }

/* ---------- language picker ---------- */
.lang-pop {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  min-width: 200px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  animation: popIn .16s ease;
}
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -48%); } to { opacity: 1; transform: translate(-50%, -50%); } }
.lang-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft, inherit);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.lang-item:hover { background: var(--hover, rgba(79, 124, 255, .08)); }
.lang-item.active { font-weight: 600; color: var(--primary); }
