/* Notizen-App — Layout & Komponenten. Farben ausschließlich über die
   Depot-Tokens (design/tokens.css) bzw. die daraus abgeleiteten,
   gedämpften Zettelfarben unten. */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Menüleiste ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  z-index: 50;
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
  margin-right: 12px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}

.topbar-spacer { flex: 1; }

.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: color-mix(in oklab, var(--foreground) 8%, transparent); }
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }
.icon-btn svg[fill="none"] { fill: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover { background: color-mix(in oklab, var(--primary) 88%, var(--foreground)); }

.btn-outline {
  background: var(--card);
  border-color: var(--border);
  color: var(--foreground);
}
.btn-outline:hover { background: var(--muted); }

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.btn-secondary:hover { background: color-mix(in oklab, var(--secondary) 90%, var(--secondary-foreground)); }

.btn-destructive {
  background: color-mix(in oklab, var(--destructive) 12%, transparent);
  color: var(--destructive);
}
.btn-destructive:hover { background: color-mix(in oklab, var(--destructive) 20%, transparent); }

/* Theme-Umschalter: im Hell-Modus Mond zeigen, im Dunkel-Modus Sonne */
#btn-theme .ic-sun { display: none; }
[data-theme="dark"] #btn-theme .ic-sun { display: block; }
[data-theme="dark"] #btn-theme .ic-moon { display: none; }

/* ---------- Arbeitsfläche ---------- */

.workspace {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
}

.canvas {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

/* ---------- Notizzettel ---------- */

.note {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  min-height: 120px;
  background: var(--note-bg);
  border: 1px solid var(--note-line);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.note-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  touch-action: none;
  color: color-mix(in oklab, var(--foreground) 30%, transparent);
}
.note-resize svg { width: 100%; height: 100%; display: block; }
.note-resize:hover { color: color-mix(in oklab, var(--foreground) 55%, transparent); }

.note.dragging { opacity: 0.92; cursor: grabbing; }

.note-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 6px 0 12px;
  background: var(--note-bar);
  border-bottom: 1px solid var(--note-line);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.note-bar:active { cursor: grabbing; }

.note-title {
  flex: 1 1 auto;
  font-size: 12.5px;
  font-weight: 600;
  color: color-mix(in oklab, var(--foreground) 78%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  min-width: 20px;
  border-radius: 6px;
  padding: 1px 4px;
  margin-left: -4px;
}
.note-title:empty::before {
  content: attr(data-ph);
  color: color-mix(in oklab, var(--foreground) 38%, transparent);
  font-weight: 500;
}
.note-title.editing {
  background: color-mix(in oklab, var(--card) 65%, transparent);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--ring) 30%, transparent);
  cursor: text;
  user-select: text;
}

.note-close {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: color-mix(in oklab, var(--foreground) 55%, transparent);
  cursor: pointer;
  padding: 0;
}
.note-close:hover {
  background: color-mix(in oklab, var(--destructive) 14%, transparent);
  color: var(--destructive);
}
.note-close svg { width: 13px; height: 13px; }

.note-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  outline: none;
  cursor: text;
  overflow-wrap: break-word;
}
.note-body:empty::before {
  content: 'Notiz …';
  color: color-mix(in oklab, var(--foreground) 32%, transparent);
}
.note-body h1, .note-body h2, .note-body h3 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0.7em 0 0.35em;
}
.note-body h1 { font-size: 1.45em; font-weight: 800; }
.note-body h2 { font-size: 1.25em; font-weight: 700; }
.note-body h3 { font-size: 1.1em; font-weight: 700; }
.note-body > *:first-child { margin-top: 0; }
.note-body p, .note-body div { margin: 0; }
.note-body ul, .note-body ol { margin: 0.35em 0; padding-left: 1.4em; }
.note-body a {
  color: var(--link);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.note-body a:hover { color: var(--link-hover); }

/* Gedämpfte Zettelfarben — Grundton wechselt (Mint, Pfirsich, Himmel,
   Flieder, Rosé, Sand), Sättigung bewusst niedrig. Fensterleiste je
   eine Nuance dunkler. */

.note-c0 { --note-bg: oklch(0.955 0.024 163); --note-bar: oklch(0.915 0.042 163); --note-line: oklch(0.855 0.05 163); }
.note-c1 { --note-bg: oklch(0.958 0.028 80);  --note-bar: oklch(0.922 0.05 80);   --note-line: oklch(0.865 0.06 80); }
.note-c2 { --note-bg: oklch(0.955 0.022 233); --note-bar: oklch(0.918 0.038 233); --note-line: oklch(0.86 0.046 233); }
.note-c3 { --note-bg: oklch(0.957 0.022 300); --note-bar: oklch(0.922 0.036 300); --note-line: oklch(0.868 0.044 300); }
.note-c4 { --note-bg: oklch(0.957 0.019 13);  --note-bar: oklch(0.924 0.033 13);  --note-line: oklch(0.87 0.04 13); }
.note-c5 { --note-bg: oklch(0.958 0.018 84);  --note-bar: oklch(0.925 0.032 84);  --note-line: oklch(0.868 0.04 84); }

[data-theme="dark"] .note-c0 { --note-bg: oklch(0.255 0.02 163); --note-bar: oklch(0.3 0.03 163); --note-line: oklch(0.36 0.035 163); }
[data-theme="dark"] .note-c1 { --note-bg: oklch(0.26 0.022 80);  --note-bar: oklch(0.305 0.032 80);  --note-line: oklch(0.365 0.038 80); }
[data-theme="dark"] .note-c2 { --note-bg: oklch(0.255 0.02 233); --note-bar: oklch(0.3 0.03 233); --note-line: oklch(0.36 0.035 233); }
[data-theme="dark"] .note-c3 { --note-bg: oklch(0.258 0.02 300); --note-bar: oklch(0.302 0.03 300); --note-line: oklch(0.362 0.035 300); }
[data-theme="dark"] .note-c4 { --note-bg: oklch(0.258 0.018 13); --note-bar: oklch(0.302 0.028 13); --note-line: oklch(0.362 0.033 13); }
[data-theme="dark"] .note-c5 { --note-bg: oklch(0.26 0.015 84);  --note-bar: oklch(0.305 0.024 84);  --note-line: oklch(0.365 0.03 84); }

/* ---------- Dialoge ---------- */

.dialog-overlay[hidden] { display: none; }

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: oklch(0.2 0.02 60 / 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dialog {
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

.dialog h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}

.dialog p {
  font-size: 14px;
  margin: 0 0 10px;
  color: var(--muted-foreground);
}

.dialog .dialog-warn {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: color-mix(in oklab, var(--warning) 13%, transparent);
  border: 1px solid color-mix(in oklab, var(--warning) 40%, transparent);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--foreground);
  margin: 14px 0;
}
.dialog .dialog-warn svg { flex: 0 0 auto; width: 16px; height: 16px; margin-top: 1px; color: var(--warning); }

.dialog input[type="text"], .dialog input[type="url"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 0 12px;
  outline: none;
  margin: 6px 0 4px;
}
.dialog input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent);
}

.dialog .share-link {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 14px 0 4px;
}
.dialog .share-link code {
  flex: 1 1 auto;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--code-inline-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  overflow-x: auto;
  white-space: nowrap;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
