:root{
  --bg:#f3f6fb;
  --surface:#ffffff;
  --surface-2:#f8fafc;
  --text:#162133;
  --muted:#6f7c8f;
  --border:#dce4ef;
  --blue:#0f76f6;
  --blue2:#0863d7;
  --sidebar:#081426;
  --sidebar-hover:#102642;
  --sidebar-text:#b8c5d7;
  --shadow:0 10px 30px rgba(19,35,55,.07);
  font-family:Inter,Segoe UI,Arial,sans-serif;
}

html[data-theme="dark"]{
  --bg:#071321;
  --surface:#111e2f;
  --surface-2:#0b1727;
  --text:#edf2f8;
  --muted:#9babc0;
  --border:#304259;
  --blue:#167cff;
  --blue2:#0b66dc;
  --sidebar:#06111f;
  --sidebar-hover:#112641;
  --sidebar-text:#c2ccda;
  --shadow:0 12px 32px rgba(0,0,0,.25);
  color-scheme:dark;
}

*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0;background:var(--bg);color:var(--text);min-height:100vh}
button,input,textarea,select{font:inherit}
a{color:inherit}
button{cursor:pointer}

.app-shell{min-height:100vh;display:grid;grid-template-columns:262px minmax(0,1fr)}
.sidebar{position:sticky;top:0;height:100vh;padding:20px 14px 16px;background:var(--sidebar);border-right:1px solid #223249;display:flex;flex-direction:column;color:#fff}
.brand{display:flex;gap:11px;align-items:center;text-decoration:none;padding:0 9px 24px}
.brand-icon{width:40px;height:40px;border-radius:12px;background:linear-gradient(145deg,#1681ff,#095ed7);display:grid;place-items:center;color:#fff;font-size:12px;font-weight:900;box-shadow:0 8px 20px rgba(15,118,246,.28)}
.brand-copy strong,.brand-copy span{display:block}
.brand-copy strong{font-size:16px;color:#fff}
.brand-copy span{font-size:11px;color:#7c8fa8;margin-top:2px}

.nav{display:flex;flex-direction:column;gap:6px}
.nav-section-title{padding:20px 11px 7px;color:#687a93;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.12em}
.nav-link{width:100%;min-height:44px;border:0;border-radius:9px;padding:0 12px;background:transparent;color:var(--sidebar-text);display:flex;align-items:center;gap:11px;text-decoration:none;font-weight:700;text-align:left}
.nav-link:hover{background:var(--sidebar-hover);color:#fff}
.nav-link.active{background:linear-gradient(90deg,#113b72,#12345e);color:#fff;box-shadow:inset 3px 0 #1681ff}
.nav-icon{width:21px;height:21px;border:1px solid #51647e;border-radius:6px;display:grid;place-items:center;color:#80b3ff;font-size:10px;font-weight:900}
.theme-row .switch{margin-left:auto;width:38px;height:22px;border-radius:999px;background:#2b3c52;padding:2px}
.theme-row .switch>span{display:block;width:18px;height:18px;border-radius:50%;background:#fff;transition:.18s}
.theme-row.on .switch{background:#167cff}
.theme-row.on .switch>span{transform:translateX(16px)}

.sidebar-footer{margin-top:auto;padding:16px 8px 0;border-top:1px solid #213149;display:grid;grid-template-columns:38px minmax(0,1fr);gap:10px;align-items:center}
.avatar{width:38px;height:38px;border-radius:50%;background:#167cff;display:grid;place-items:center;font-weight:900}
.user-copy strong,.user-copy span{display:block}
.user-copy strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.user-copy span{font-size:11px;color:#8293aa}
.sidebar-footer form{grid-column:1/-1;margin:5px 0 0}
.signout-button{width:100%;padding:8px;border:1px solid #2b405d;background:#112239;color:#cbd5e3;border-radius:8px}

.workspace{min-width:0}
.topbar{position:sticky;top:0;z-index:30;min-height:78px;padding:14px 28px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:20px;background:color-mix(in srgb,var(--bg) 92%,transparent);backdrop-filter:blur(15px)}
.global-search{width:min(440px,58vw);height:44px;border:1px solid var(--border);background:var(--surface);border-radius:10px;display:flex;align-items:center;gap:9px;padding:0 12px}
.search-symbol{color:var(--muted);font-size:11px;font-weight:900}
.global-search input{flex:1;min-width:0;border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;color:var(--text)!important;outline:none}
.global-search kbd{padding:4px 7px;border-radius:6px;background:var(--surface-2);color:var(--muted);font-size:11px}
.top-add-note{margin-left:auto;min-height:42px;display:inline-flex;align-items:center;padding:0 16px;border-radius:9px;background:linear-gradient(180deg,var(--blue),var(--blue2));color:#fff;text-decoration:none;font-weight:800;box-shadow:0 8px 18px rgba(15,118,246,.2)}
.content{padding:28px}
.page-heading,.settings-page,.composer-card,.notes-toolbar,.notes-list{max-width:1180px;margin-left:auto;margin-right:auto}
.page-heading{margin-bottom:20px}
.page-heading h1{margin:0 0 5px;font-size:30px;letter-spacing:-.03em}
.page-heading p{margin:0;color:var(--muted)}

.surface{background:var(--surface);border:1px solid var(--border);border-radius:15px;box-shadow:var(--shadow)}
.composer-card{padding:22px;margin-bottom:28px}
.section-heading{display:flex;align-items:center;gap:11px;padding-bottom:17px;margin-bottom:18px;border-bottom:1px solid var(--border)}
.section-icon{width:34px;height:34px;border-radius:9px;background:color-mix(in srgb,var(--blue) 13%,var(--surface));color:var(--blue);display:grid;place-items:center;font-size:18px;font-weight:900}
.section-heading h2{margin:0;font-size:20px}
.section-heading p{margin:2px 0 0;color:var(--muted);font-size:12px}

.note-form{display:grid;grid-template-columns:1fr 1fr;gap:16px 18px}
.note-form label{display:grid;gap:7px;font-size:13px;font-weight:800}
.note-form label>span em{font-style:normal;color:var(--muted);font-weight:500}
.note-form .full{grid-column:1/-1}
input,textarea,select{width:100%;border:1px solid var(--border);border-radius:10px;background:var(--surface-2);color:var(--text);padding:11px 12px;outline:none}
input:focus,textarea:focus,select:focus{border-color:var(--blue);box-shadow:0 0 0 3px color-mix(in srgb,var(--blue) 17%,transparent)}
textarea{resize:vertical;min-height:145px}
input[type=file]{padding:8px}
input[type=file]::file-selector-button{border:0;border-radius:7px;background:color-mix(in srgb,var(--blue) 13%,var(--surface));color:var(--blue);padding:7px 10px;font-weight:800;margin-right:9px}
.primary-button{border:0;border-radius:10px;background:linear-gradient(180deg,var(--blue),var(--blue2));color:#fff;padding:12px 16px;font-weight:900;box-shadow:0 8px 18px rgba(15,118,246,.2)}

.notes-toolbar{display:flex;justify-content:space-between;align-items:end;gap:20px;margin-bottom:13px}
.notes-toolbar h2{margin:0;font-size:21px}
.notes-toolbar p{margin:2px 0 0;color:var(--muted);font-size:12px}
.notes-filters{display:grid;grid-template-columns:minmax(180px,1fr) 150px auto;gap:9px;width:min(560px,60vw)}
.filter-button{border:1px solid var(--border);background:var(--surface);color:var(--text);border-radius:9px;padding:0 13px;font-weight:800}
.notes-list{display:grid;gap:11px}
.note-card{position:relative;padding:18px;display:grid;grid-template-columns:44px minmax(0,1fr);gap:14px;overflow:hidden}
.note-card:before{content:"";position:absolute;inset:0 auto 0 0;width:3px;background:var(--blue)}
.note-card.completed:before{background:#2ab673}
.note-glyph{width:44px;height:44px;border-radius:11px;background:color-mix(in srgb,var(--blue) 12%,var(--surface));color:var(--blue);display:grid;place-items:center;font-weight:900}
.note-main{min-width:0}
.note-title-row{display:flex;justify-content:space-between;gap:15px;align-items:start}
.note-title-row h3{display:inline;margin:0 8px 0 0;font-size:16px}
.type-badge{display:inline-flex;padding:3px 7px;border-radius:999px;background:color-mix(in srgb,var(--blue) 12%,var(--surface));color:var(--blue);font-size:11px;font-weight:800}
.delete-button{border:1px solid color-mix(in srgb,#d64555 35%,var(--border));background:transparent;color:#d64555;border-radius:8px;padding:5px 8px;font-size:11px}
.note-content{margin:9px 0;color:var(--muted);line-height:1.55}
.note-meta-row{display:flex;gap:14px;align-items:center;flex-wrap:wrap;color:var(--muted);font-size:11px}
.complete-form{margin-left:auto}
.complete-check{display:flex;align-items:center;gap:6px;font-weight:700}
.complete-check input{width:16px;height:16px;accent-color:#2ab673}
.attachment-row{margin-top:11px;padding:9px 11px;border-radius:9px;background:var(--surface-2);display:flex;gap:8px;align-items:center;font-size:12px}
.paperclip{color:var(--blue);font-weight:900}
.attachment-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.download-link{margin-left:auto;color:var(--blue);font-weight:800;text-decoration:none}
.empty-state{text-align:center;padding:34px}
.empty-state p{color:var(--muted)}

.settings-page{padding-bottom:40px}
.back-link{display:inline-block;margin-bottom:14px;color:var(--blue);font-size:13px;font-weight:800;text-decoration:none}
.settings-title{display:flex;gap:14px;align-items:center;margin-bottom:20px}
.shield-icon{width:42px;height:46px;border:2px solid var(--blue);border-radius:15px 15px 19px 19px;display:grid;place-items:center;color:var(--blue);font-weight:900}
.settings-title h1{margin:0 0 4px;font-size:25px}
.settings-title p{margin:0;color:var(--muted)}
.alert{padding:12px 14px;border-radius:10px;margin-bottom:16px;font-weight:700}
.alert.error{background:#fff0f2;border:1px solid #f1c2ca;color:#a92e3d}
.alert.success{background:#eaf8f0;border:1px solid #b8e4ca;color:#176b45}
html[data-theme=dark] .alert.error{background:#2c171e;border-color:#643443;color:#ff9faf}
html[data-theme=dark] .alert.success{background:#102b21;border-color:#2a604d;color:#87d8b0}

.password-form{display:grid}
.settings-card{padding:26px}
.settings-card h2{margin:8px 0 4px;font-size:19px}
.settings-card>p{margin:0 0 20px;color:var(--muted)}
.step-badge{display:inline-flex;padding:5px 9px;border-radius:7px;background:color-mix(in srgb,var(--blue) 17%,var(--surface));color:#65a6ff;font-size:12px;font-weight:800}
.password-field{display:grid;gap:7px;max-width:540px;font-size:13px;font-weight:800}
.password-input{display:flex;align-items:center;border:1px solid var(--border);border-radius:9px;background:var(--surface-2)}
.password-input:focus-within{border-color:var(--blue);box-shadow:0 0 0 3px color-mix(in srgb,var(--blue) 17%,transparent)}
.password-input input{border:0!important;background:transparent!important;box-shadow:none!important}
.show-password{margin-right:6px;border:0;background:transparent;color:var(--muted);padding:6px 8px;font-size:11px}
.flow-arrow{width:48px;height:48px;border:1px solid var(--border);border-radius:50%;background:var(--surface);color:var(--blue);display:grid;place-items:center;margin:-1px auto;z-index:2;font-size:22px}
.password-layout{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(280px,.85fr);gap:28px}
.password-requirements,.password-tips ul{color:var(--muted);font-size:12px;line-height:1.7;padding-left:19px}
.password-tips{border:1px solid var(--border);border-radius:13px;background:var(--surface-2);padding:22px}
.password-tips h3{margin:0 0 5px;color:var(--blue)}
.password-tips p{color:var(--muted);font-size:13px}
.update-password{margin-top:20px}

.login-page{min-height:100vh;display:grid;place-items:center;padding:24px;background:var(--bg)}
.login-card{width:min(430px,100%);padding:34px;border:1px solid var(--border);border-radius:20px;background:var(--surface);box-shadow:var(--shadow)}
.login-logo{width:52px;height:52px;border-radius:15px;background:var(--blue);display:grid;place-items:center;color:#fff;font-weight:900}
.login-card h1{margin:16px 0 4px}
.login-card p{margin:0 0 20px;color:var(--muted)}
.login-form{display:grid;gap:16px}
.login-form label{display:grid;gap:7px;font-size:13px;font-weight:800}

@media(max-width:900px){
  .app-shell{grid-template-columns:1fr}
  .sidebar{position:relative;height:auto}
  .nav{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}
  .nav-section-title,.sidebar-footer{display:none}
  .topbar{padding:12px 15px}
  .global-search{width:100%}
  .global-search kbd{display:none}
  .content{padding:20px 14px}
}
@media(max-width:720px){
  .nav{grid-template-columns:1fr 1fr}
  .note-form{grid-template-columns:1fr}
  .note-form .full{grid-column:1}
  .notes-toolbar{align-items:stretch;flex-direction:column}
  .notes-filters{width:100%;grid-template-columns:1fr}
  .note-card{grid-template-columns:36px minmax(0,1fr);padding:14px}
  .note-glyph{width:36px;height:36px}
  .complete-form{margin-left:0}
  .password-layout{grid-template-columns:1fr}
}

/* ===== Compact Composer Layout START ===== */

/* Keep the Add a note panel compact at the top */
.composer-card{
  max-width:1180px;
  margin:0 auto 20px;
  padding:18px 18px 16px;
}

.composer-card .section-heading{
  padding-bottom:12px;
  margin-bottom:14px;
}

.composer-card .section-heading h2{
  font-size:18px;
}

.composer-card .section-heading p{
  display:none;
}

/*
  Compact desktop layout:
  left side = Date / Title / Type / File / Save
  right side = Note
*/
.note-form{
  display:grid;
  grid-template-columns:minmax(250px,.85fr) minmax(420px,1.65fr);
  grid-template-areas:
    "date note"
    "title note"
    "type note"
    "file note"
    "save note";
  gap:10px 20px;
  align-items:start;
}

/* Map the current form fields without changing any backend functionality */
.note-form > label:nth-of-type(1){ grid-area:date; }
.note-form > label:nth-of-type(2){ grid-area:title; }
.note-form > label:nth-of-type(3){ grid-area:type; }
.note-form > label:nth-of-type(4){ grid-area:note; }
.note-form > label:nth-of-type(5){ grid-area:file; }

.note-form > button[type="submit"]{
  grid-area:save;
  width:100%;
  min-height:40px;
  margin:0;
}

/* Override the old full-width rules */
.note-form .full{
  grid-column:auto;
}

.note-form label{
  gap:5px;
}

.note-form input,
.note-form select{
  min-height:40px;
  padding:9px 10px;
}

.note-form textarea{
  min-height:164px;
  height:100%;
  padding:10px 11px;
}

/* Make the upload row compact */
.note-form input[type="file"]{
  min-height:40px;
  padding:5px 7px;
}

/* Notes always sit below the Add a note panel */
.notes-toolbar{
  max-width:1180px;
  margin:0 auto 12px;
  padding-top:2px;
}

.notes-list{
  max-width:1180px;
  margin:0 auto;
  display:grid;
  grid-template-columns:1fr;
  gap:9px;
}

/* Smaller, cleaner note rows */
.note-card{
  padding:14px 16px;
  grid-template-columns:40px minmax(0,1fr);
  gap:12px;
  border-radius:12px;
}

.note-glyph{
  width:40px;
  height:40px;
  border-radius:10px;
}

.note-title-row h3{
  font-size:15px;
}

.note-content{
  margin:6px 0;
  font-size:13px;
}

.note-meta-row{
  gap:11px;
  font-size:10.5px;
}

.attachment-row{
  margin-top:8px;
  padding:7px 9px;
}

/* Keep search/filter controls on the same row when space allows */
.notes-toolbar{
  display:flex;
  align-items:end;
  justify-content:space-between;
  gap:16px;
}

.notes-filters{
  width:min(520px,58vw);
}

/* Responsive fall-back */
@media(max-width:900px){
  .note-form{
    grid-template-columns:1fr;
    grid-template-areas:
      "date"
      "title"
      "type"
      "note"
      "file"
      "save";
  }

  .note-form textarea{
    min-height:135px;
  }

  .notes-toolbar{
    align-items:stretch;
    flex-direction:column;
  }

  .notes-filters{
    width:100%;
  }
}

/* ===== Compact Composer Layout END ===== */



/* ===== Daily Notes 2FA START ===== */
.twofactor-cancel{
  display:block;
  margin-top:16px;
  text-align:center;
  color:var(--muted);
  text-decoration:none;
  font-size:13px;
}

.twofactor-setup-card{
  max-width:760px;
}

.twofactor-qr-wrap{
  width:max-content;
  margin:20px 0;
  padding:14px;
  border-radius:14px;
  background:#fff;
  border:1px solid var(--border);
}

.twofactor-qr{
  display:block;
  width:230px;
  height:230px;
  image-rendering:pixelated;
}

.twofactor-manual{
  display:grid;
  gap:7px;
  padding:13px 15px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--surface-2);
}

.twofactor-manual span{
  color:var(--muted);
  font-size:12px;
}

.twofactor-manual strong{
  overflow-wrap:anywhere;
  font-family:Consolas,monospace;
  letter-spacing:.08em;
}

.twofactor-divider{
  height:1px;
  margin:24px 0;
  background:var(--border);
}

.twofactor-enable-form{
  display:grid;
  gap:14px;
  max-width:420px;
}

.twofactor-enable-form label{
  display:grid;
  gap:7px;
  font-weight:800;
  font-size:13px;
}

.twofactor-enable-form input[name="code"],
.twofactor-login-card input[name="code"]{
  font-size:22px;
  font-weight:800;
  letter-spacing:.28em;
  text-align:center;
}

.twofactor-enabled-badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  margin-bottom:22px;
  padding:8px 11px;
  border-radius:999px;
  background:color-mix(in srgb,#27b36a 15%,var(--surface));
  color:#27b36a;
  font-weight:800;
  font-size:13px;
}

.twofactor-disable-form{
  display:grid;
  gap:16px;
  max-width:540px;
}

.danger-twofactor-button{
  width:max-content;
  border:1px solid #b83c4a;
  border-radius:9px;
  padding:10px 14px;
  background:#b83c4a;
  color:#fff;
  font-weight:800;
}
/* ===== Daily Notes 2FA END ===== */

/* ===== Permanent Dark Mode Fallback START ===== */

/*
  Permanent dark-mode fallback.
  These values mirror the site's dark theme even if JavaScript is disabled
  or a browser has an old light-mode preference cached.
*/
:root,
html,
html[data-theme="dark"]{
  color-scheme:dark;
  --bg:#071321;
  --surface:#111e2f;
  --surface-2:#0b1727;
  --text:#edf2f8;
  --muted:#9babc0;
  --border:#304259;
  --blue:#167cff;
  --blue2:#0b66dc;
  --sidebar:#06111f;
  --sidebar-hover:#112641;
  --sidebar-text:#c2ccda;
  --shadow:0 12px 32px rgba(0,0,0,.25);
}

html,
body{
  background:#071321 !important;
  color:#edf2f8 !important;
}

.workspace,
.content,
.login-page,
.settings-page{
  background-color:var(--bg);
}

/* Keep cards and inputs dark even if another older rule tries to restore light colours. */
.surface,
.login-card,
.settings-card,
.composer-card,
.note-card,
.global-search{
  background-color:var(--surface);
  color:var(--text);
  border-color:var(--border);
}

input,
textarea,
select{
  background-color:var(--surface-2) !important;
  color:var(--text) !important;
  border-color:var(--border) !important;
}

/* ===== Permanent Dark Mode Fallback END ===== */

/* ===== Permanent Clouds Background START ===== */

/*
  Permanent clouds background for the MAIN Daily Notes content only.
  The left sidebar and top bar keep their normal dark colours.
*/
.content{
  min-height:calc(100vh - 78px);
  background:
    linear-gradient(rgba(7,19,33,.60), rgba(7,19,33,.60)),
    url("/images/daily-notes-background.jpg") center center / cover fixed no-repeat !important;
}

/* Keep the top bar and sidebar independent from the clouds background */
.sidebar{
  background:var(--sidebar) !important;
}

.topbar{
  background:color-mix(in srgb,var(--bg) 92%,transparent) !important;
  backdrop-filter:blur(15px);
}

/* Ensure the workspace outside content remains dark */
.workspace{
  background:var(--bg);
}

/* ===== Permanent Clouds Background END ===== */
