/* Noter — udseende som Apple Noter (iOS på telefonen, macOS på store skærme). */
:root {
  --accent: #e0a100;
  --accent-press: #b98500;
  --bg: #f2f2f7;
  --cell: #ffffff;
  --text: #000000;
  --text2: #8a8a8e;
  --text3: #c4c4c7;
  --sep: rgba(60, 60, 67, 0.17);
  --fill: rgba(118, 118, 128, 0.12);
  --sidebar: #ececee;
  --editor: #ffffff;
  --bar: rgba(242, 242, 247, 0.82);
  --bar-editor: rgba(255, 255, 255, 0.85);
  --sel: #fbd24e;
  --sel-text: #000;
  --sel-folder: rgba(0, 0, 0, 0.09);
  --menu: rgba(250, 250, 252, 0.92);
  --danger: #ff3b30;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, Ubuntu, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --kb: 0px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #ffcc00;
    --accent-press: #d9ad00;
    --bg: #000000;
    --cell: #1c1c1e;
    --text: #ffffff;
    --text2: #98989f;
    --text3: #545458;
    --sep: rgba(84, 84, 88, 0.65);
    --fill: rgba(118, 118, 128, 0.24);
    --sidebar: #232325;
    --editor: #1c1c1e;
    --bar: rgba(0, 0, 0, 0.8);
    --bar-editor: rgba(0, 0, 0, 0.8);
    --sel: #7a6420;
    --sel-text: #fff;
    --sel-folder: rgba(255, 255, 255, 0.1);
    --menu: rgba(44, 44, 46, 0.94);
    --danger: #ff453a;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.1);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  font-size: 17px;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; flex: none; }

/* Splash og login */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.splash img { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 8px 30px rgba(0,0,0,.12); animation: pop .5s ease both; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--bg); overflow: auto; }
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 36px 28px 28px; background: var(--cell); border-radius: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.07); }
.login-icon { width: 92px; height: 92px; border-radius: 21px; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.login h1 { font-size: 30px; margin: 14px 0 6px; letter-spacing: -0.02em; }
.login-text { color: var(--text2); font-size: 15px; line-height: 1.4; margin: 0 0 20px; }
.login-text b { color: var(--text); font-weight: 600; }
.login input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 0; background: var(--fill); font-size: 17px; outline: none; text-align: center; }
.login input:focus { box-shadow: 0 0 0 2px var(--accent); }
#login-code { letter-spacing: 0.25em; font-variant-numeric: tabular-nums; font-size: 22px; }
.login-btn { width: 100%; margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; font-size: 17px; }
@media (prefers-color-scheme: dark) { .login-btn { color: #000; } }
.login-btn:active { background: var(--accent-press); }
.login-btn:disabled { opacity: .6; }
.login-link { margin-top: 14px; color: var(--accent); font-size: 15px; }
.login-error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 14px 0 0; }

/* Ruder (telefon: én ad gangen, som på iPhone) */
.app { position: fixed; inset: 0; overflow: hidden; }
.pane {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  transition: transform .38s cubic-bezier(.2, .85, .25, 1), box-shadow .38s;
  will-change: transform;
}
.pane-folders { z-index: 1; }
.pane-list { z-index: 2; }
.pane-editor { z-index: 3; background: var(--editor); }
@media (prefers-color-scheme: dark) { .pane-editor { background: #000; } }
.app[data-view="folders"] .pane-list,
.app[data-view="folders"] .pane-editor,
.app[data-view="list"] .pane-editor { transform: translateX(100%); }
.app[data-view="list"] .pane-folders,
.app[data-view="note"] .pane-folders,
.app[data-view="note"] .pane-list { transform: translateX(-28%); }
.app[data-view="note"] .pane-editor,
.app[data-view="list"] .pane-list { box-shadow: -8px 0 30px rgba(0,0,0,.08); }
.app.no-anim .pane { transition: none; }

.bar {
  flex: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: calc(44px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0;
  position: relative; z-index: 5;
  transition: background .2s, border-color .2s;
  border-bottom: 0.5px solid transparent;
}
.bar.scrolled { background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom-color: var(--sep); }
.pane-editor .bar.scrolled { background: var(--bar-editor); }
.bar-title { font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }
.bar.scrolled .bar-title { opacity: 1; }
.bar-side { display: flex; align-items: center; gap: 4px; min-width: 0; }
.bar-side.right { justify-content: flex-end; }
.back-btn { display: flex; align-items: center; color: var(--accent); font-size: 17px; padding: 8px 4px; margin-left: -4px; }
.back-btn svg { width: 22px; height: 22px; margin-right: 1px; }
.back-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--accent); }
.icon-btn:active { opacity: .5; }
.icon-btn.small { width: 30px; height: 30px; color: var(--text2); background: var(--fill); border-radius: 50%; }
.icon-btn.small svg { width: 16px; height: 16px; }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.done-btn { color: var(--accent); font-weight: 600; font-size: 17px; padding: 8px 10px; }
.desktop-only { display: none !important; }

.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 24px; }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 20px 10px; line-height: 1.15; }
.group-title { font-size: 20px; font-weight: 700; margin: 18px 20px 8px; }

.tools {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  height: calc(46px + env(safe-area-inset-bottom)); padding: 0 8px env(safe-area-inset-bottom);
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tools-text { font-size: 12px; color: var(--text); }
#sync-status { color: var(--text2); }
.icon-spacer { width: 40px; }
.editor-tools { background: var(--bar-editor); position: relative; bottom: var(--kb); transition: none; }
.app.keyboard .editor-tools { padding-bottom: 0; height: 46px; }

/* Mapper */
.folder-list { list-style: none; margin: 0 16px; padding: 0; background: var(--cell); border-radius: 12px; overflow: hidden; }
.folder-row { display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px; min-height: 46px; cursor: default; position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.folder-row svg.fi { color: var(--accent); width: 26px; height: 26px; }
.folder-row .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-row .count { color: var(--text2); font-variant-numeric: tabular-nums; }
.folder-row .chev { color: var(--text3); width: 18px; height: 18px; }
.folder-row + .folder-row::before { content: ""; position: absolute; top: 0; left: 54px; right: 0; border-top: 0.5px solid var(--sep); }
.folder-row:active { background: var(--fill); }

/* Søgning */
.search { display: flex; align-items: center; gap: 6px; margin: 0 16px 10px; padding: 0 8px; height: 36px; background: var(--fill); border-radius: 10px; color: var(--text2); }
.search svg { width: 18px; height: 18px; }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 17px; min-width: 0; height: 100%; }
.search input::placeholder { color: var(--text2); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

/* Noteliste */
.section-title { font-size: 20px; font-weight: 700; margin: 18px 20px 8px; display: flex; align-items: center; gap: 6px; }
.section-title svg { width: 18px; height: 18px; color: var(--accent); }
.note-group { margin: 0 16px; background: var(--cell); border-radius: 12px; overflow: hidden; }
.note-row { display: block; padding: 11px 16px; position: relative; cursor: default; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.note-row + .note-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.note-row:active { background: var(--fill); }
.note-title { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.note-sub { font-size: 15px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; line-height: 1.3; }
.note-sub time { color: var(--text); margin-right: 6px; opacity: .85; }
.note-folder { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 4px; margin-top: 3px; }
.note-folder svg { width: 15px; height: 15px; }
.note-thumb { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 6px; object-fit: cover; }
.note-row.has-thumb { padding-right: 70px; }
.list-empty { text-align: center; color: var(--text2); margin-top: 22vh; font-size: 17px; }

/* Editor */
.pane-editor .scroll { padding: 0 20px calc(40px + var(--kb)); }
.note-date { text-align: center; color: var(--text2); font-size: 13px; margin: 2px 0 14px; }
.editor {
  outline: none; min-height: 60vh; font-size: 17px; line-height: 1.45;
  word-wrap: break-word; overflow-wrap: anywhere; caret-color: var(--accent);
  padding-bottom: 30vh;
}
.editor > :first-child, .editor h1 { font-size: 1.65em; font-weight: 700; line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 .15em; }
.editor h2 { font-size: 1.3em; font-weight: 700; margin: .3em 0 .1em; line-height: 1.25; }
.editor h3 { font-size: 1.08em; font-weight: 600; margin: .2em 0 0; }
.editor > :first-child:is(ul, ol) { font-size: 1em; font-weight: 400; }
.editor div, .editor p { margin: 0; }
.editor pre { font-family: var(--mono); font-size: .88em; white-space: pre-wrap; margin: 0; }
.editor ul, .editor ol { margin: 0; padding-left: 1.6em; }
.editor ul.dashed { list-style: none; }
.editor ul.dashed > li { position: relative; }
.editor ul.dashed > li::before { content: "–"; position: absolute; left: -1.1em; }
.editor ul.checklist { list-style: none; padding-left: 0; }
.editor ul.checklist > li { position: relative; padding-left: 34px; min-height: 1.45em; margin: 3px 0; transition: color .2s; }
.editor ul.checklist > li::before {
  content: ""; position: absolute; left: 1px; top: .1em; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--text3); box-sizing: border-box; cursor: pointer; transition: background .15s, border-color .15s;
}
.editor ul.checklist > li.checked { color: var(--text2); }
.editor ul.checklist > li.checked::before {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6.5 12.5 3.6 3.6 7.4-8' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/15px no-repeat;
}
.editor img { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 6px 0; }
.editor a { color: var(--accent); }
.editor blockquote { border-left: 3px solid var(--accent); margin: 0; padding-left: 10px; color: var(--text2); }
.editor[contenteditable="false"] { opacity: .75; }
.editor-empty { display: grid; place-items: center; text-align: center; color: var(--text2); margin-top: 28vh; }
.editor-empty svg { width: 54px; height: 54px; color: var(--text3); }
.trash-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--fill); border-radius: 10px; padding: 10px 14px; margin: 4px 0 12px; font-size: 15px; color: var(--text2); }
.trash-banner button { color: var(--accent); font-weight: 600; }

/* Formatpanel (bundark på telefonen, popover på store skærme) */
.format-panel {
  position: fixed; left: 0; right: 0; bottom: var(--kb); z-index: 40;
  background: var(--cell); border-radius: 16px 16px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 30px rgba(0,0,0,.14); animation: sheet .25s cubic-bezier(.2,.85,.25,1);
}
.app.keyboard ~ .format-panel { padding-bottom: 16px; }
@keyframes sheet { from { transform: translateY(100%); } }
.format-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 18px; }
.format-styles { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.format-styles button { flex: none; padding: 8px 12px; border-radius: 9px; background: var(--fill); white-space: nowrap; }
.format-styles button.on { background: var(--accent); color: #fff; }
.fs-title { font-weight: 700; font-size: 20px; }
.fs-heading { font-weight: 700; font-size: 17px; }
.fs-sub { font-weight: 600; font-size: 15px; }
.fs-body { font-size: 15px; }
.fs-mono { font-family: var(--mono); font-size: 14px; }
.format-row { display: flex; gap: 10px; margin-top: 12px; }
.segmented { display: flex; flex: 1; background: var(--fill); border-radius: 9px; overflow: hidden; }
.segmented button { flex: 1; height: 40px; font-size: 18px; }
.segmented button + button { border-left: 0.5px solid var(--sep); }
.segmented button.on { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .segmented button.on, .format-styles button.on { color: #000; } }

/* Menu og dialog */
.menu {
  position: fixed; z-index: 60; min-width: 230px; max-width: calc(100vw - 32px);
  background: var(--menu); backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px);
  border-radius: 14px; box-shadow: var(--shadow); padding: 5px 0; overflow: hidden;
  animation: menu .18s ease-out; transform-origin: top left;
}
@keyframes menu { from { opacity: 0; transform: scale(.92); } }
.menu-item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 16px; font-size: 16px; text-align: left; }
.menu-item svg { width: 20px; height: 20px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--fill); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.muted { color: var(--text2); font-size: 13px; pointer-events: none; padding: 8px 16px; }
.menu-sep { height: 6px; background: var(--fill); margin: 4px 0; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.28); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: 290px; background: var(--menu); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); border-radius: 14px; text-align: center; overflow: hidden; animation: menu .2s ease-out; transform-origin: center; }
.dialog h2 { font-size: 17px; font-weight: 600; margin: 20px 16px 4px; }
.dialog p { font-size: 13px; margin: 0 16px 12px; line-height: 1.35; }
.dialog p:empty { display: none; }
.dialog input { width: calc(100% - 32px); margin: 4px 16px 16px; padding: 7px 8px; border-radius: 7px; border: 0.5px solid var(--sep); background: var(--cell); font-size: 14px; outline: none; }
.dialog-buttons { display: flex; border-top: 0.5px solid var(--sep); }
.dialog-buttons button { flex: 1; padding: 12px; color: var(--accent); font-size: 17px; }
.dialog-buttons button + button { border-left: 0.5px solid var(--sep); font-weight: 600; }
.dialog-buttons button.danger { color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; background: rgba(30,30,30,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; animation: fade .2s; max-width: calc(100vw - 32px); text-align: center; }

/* Store skærme: tre kolonner som Noter på Mac/iPad */
@media (min-width: 900px) {
  body { font-size: 14px; }
  .mobile-only { display: none !important; }
  .desktop-only { display: flex !important; }
  .app { display: grid; grid-template-columns: 230px 320px 1fr; }
  .app.no-sidebar { grid-template-columns: 0 320px 1fr; }
  .app.no-sidebar .pane-folders { visibility: hidden; }
  .pane { position: relative; inset: auto; transform: none !important; box-shadow: none !important; min-width: 0; transition: none; }
  .pane-folders { background: var(--sidebar); border-right: 0.5px solid var(--sep); }
  .pane-list { background: var(--cell); border-right: 0.5px solid var(--sep); }
  .pane-editor, .pane-editor .bar.scrolled { background: var(--editor); }
  .bar { height: 52px; padding: 0 10px; border-bottom: 0.5px solid var(--sep); }
  .bar.scrolled { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .pane-folders .bar { border-bottom-color: transparent; }
  .bar-title { opacity: 1; font-size: 14px; font-weight: 700; }
  .pane-folders .bar-title { opacity: 0; }
  .pane-editor .bar-title { visibility: hidden; }
  .toolbar-group { gap: 2px; align-items: center; }
  .icon-btn { width: 34px; height: 30px; border-radius: 7px; color: var(--text2); }
  .icon-btn:hover { background: var(--fill); }
  .icon-btn svg { width: 21px; height: 21px; }
  .icon-btn.on { background: var(--fill); color: var(--accent); }
  .large-title { display: none; }
  .tools { display: none; }
  .pane-folders .tools { display: flex; background: transparent; border-top: 0; backdrop-filter: none; -webkit-backdrop-filter: none; height: 44px; padding: 0 8px; }
  .scroll { padding-bottom: 8px; }

  .group-title { font-size: 11px; font-weight: 700; color: var(--text2); margin: 6px 18px 4px; }
  .folder-list { background: none; margin: 0 8px; border-radius: 0; }
  .folder-row { min-height: 30px; border-radius: 7px; padding: 0 10px; gap: 8px; }
  .folder-row + .folder-row::before { display: none; }
  .folder-row svg.fi { width: 19px; height: 19px; }
  .folder-row .chev { display: none; }
  .folder-row .count { font-size: 13px; }
  .folder-row.active { background: var(--sel-folder); }
  .folder-row:active { background: var(--sel-folder); }

  .search { margin: 10px 12px 6px; height: 30px; border-radius: 8px; }
  .search input { font-size: 14px; }
  .section-title { font-size: 11px; font-weight: 700; color: var(--text2); margin: 14px 22px 4px; }
  .section-title svg { width: 13px; height: 13px; color: var(--text2); }
  .note-group { background: none; margin: 0 10px; border-radius: 0; overflow: visible; }
  .note-row { padding: 9px 12px; border-radius: 9px; }
  .note-row + .note-row::before { left: 12px; right: 12px; }
  .note-row.active, .note-row.active + .note-row::before, .note-row.active::before { border-color: transparent; }
  .note-row.active { background: var(--sel); color: var(--sel-text); }
  .note-row.active .note-sub, .note-row.active .note-folder { color: var(--sel-text); opacity: .7; }
  .note-row:active { background: var(--fill); }
  .note-row.active:active { background: var(--sel); }
  .note-title { font-size: 14px; font-weight: 700; }
  .note-sub { font-size: 13px; }
  .note-sub time { color: inherit; }
  .note-folder { font-size: 12px; }
  .note-thumb { width: 40px; height: 40px; }
  .list-empty { font-size: 15px; }

  .pane-editor .scroll { padding: 8px 48px 40px; }
  .editor { font-size: 16px; min-height: 70vh; padding-bottom: 40vh; }
  .note-date { font-size: 12px; margin: 10px 0 18px; }

  .format-panel { left: auto; right: auto; bottom: auto; width: 330px; border-radius: 12px; box-shadow: var(--shadow); padding: 14px; animation: menu .15s ease-out; background: var(--menu); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); }
  .format-head { display: none; }
  .format-styles { flex-direction: column; gap: 2px; }
  .format-styles button { background: none; text-align: left; padding: 6px 10px; }
  .format-styles button:hover { background: var(--fill); }
  .menu-item { padding: 7px 14px; font-size: 14px; }
  .menu-item svg { width: 17px; height: 17px; }
  .menu { min-width: 210px; }
}
@media (min-width: 900px) and (max-width: 1100px) {
  .app { grid-template-columns: 200px 280px 1fr; }
  .pane-editor .scroll { padding: 8px 28px 40px; }
}
@media (hover: hover) {
  .folder-row:not(.active):hover, .note-row:not(.active):hover { background: var(--fill); }
}
@media print {
  .pane-folders, .pane-list, .bar, .tools { display: none !important; }
  .app { position: static; display: block; }
  .pane-editor { position: static; transform: none !important; }
}
