/* ============================================
   NOTOMA v2.3 — OS Interface × Braun × Moleskine
   ============================================ */

:root {
  --bg: #F5F1EB;
  --text: #1A1A1A;
  --accent: #C0392B;
  --line-color: #1A1A1A;
  --line-opacity: 1.00;
  --header-bg-opacity: 0.10;
  --hairline: rgba(26, 26, 26, var(--line-opacity));
  --hairline-w: 1.5px;
  --font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-body: var(--font-sans);
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  --size-header: 10px;
  --size-body: 11px;
  --size-secondary: 9px;
  --size-topbar: 11px;
  --size-focus: 16px;
  --size-temp: 14px;
  --scale: 1.27;
  --pad-widget: 12px;
  --gap-item: 8px;
  --transition-speed: 0.3s;
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-hover: 80ms ease;
  --settings-width: 220px;
}

[data-theme="dark"] {
  --bg: #1A1A1A;
  --text: #E8E4DE;
  --line-color: #E8E4DE;
  --hairline: rgba(232, 228, 222, var(--line-opacity));
}

[data-density="relaxed"] {
  --pad-widget: 16px;
  --gap-item: 12px;
}

[data-motion="off"],
[data-motion="off"] * {
  transition: none !important;
  animation: none !important;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; margin: 0; }

body {
  font-family: var(--font-body);
  font-size: calc(var(--size-body) * var(--scale));
  font-weight: 400;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  transition: background var(--transition-speed), color var(--transition-speed);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums lining-nums;
}

[data-font="serif"] body { --font-body: var(--font-serif); }

/* --- Dashboard Shell --- */
.dashboard {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
}

/* --- Top Bar --- */
.top-bar {
  --header-line-w: 0.75px;
  display: flex;
  align-items: center;
  padding: 0 var(--pad-widget);
  border-bottom: var(--header-line-w) solid var(--hairline);
  font-size: calc(var(--size-topbar) * var(--scale));
  font-weight: 400;
  min-height: 30px;
  gap: 0;
  transition: opacity 350ms ease;
}

.top-bar__logo {
  display: flex;
  align-items: baseline;
  padding: 6px 10px 6px 0;
  border-right: var(--header-line-w) solid var(--hairline);
  flex-shrink: 0;
  gap: 4px;
}
.logo-jp {
  font-size: calc(10px * var(--scale));
  opacity: 1;
  letter-spacing: 1px;
}
.logo-latin {
  font-size: calc(var(--size-header) * var(--scale));
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.top-bar__date {
  padding: 6px 12px 6px 10px;
  border-right: var(--header-line-w) solid var(--hairline);
  white-space: nowrap;
  flex-shrink: 0;
}

.top-bar__tabs {
  display: flex;
  align-items: stretch;
  height: 100%;
  gap: 0;
}

.tab {
  background: none;
  border: none;
  border-right: var(--header-line-w) solid var(--hairline);
  color: var(--text);
  font-family: var(--font-body);
  font-size: calc(var(--size-header) * var(--scale));
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 6px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 180ms ease, color var(--transition-interactive);
  opacity: 1;
  position: relative;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab:hover .tab__label-input { color: var(--text); font-weight: 500; }

.tab--active {
  opacity: 1;
  color: #D35400;
  font-weight: 700;
}

.tab--active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: #D35400;
}

.tab__label-input {
  background: none;
  border: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  outline: none;
  width: 72px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  pointer-events: none;
}
.tab__label-input--editing {
  pointer-events: auto;
  cursor: text;
  border-bottom: 1px solid var(--text);
  caret-color: #D35400;
}

/* Pencil edit icon — absolutely positioned in left padding, no layout shift */
.tab__edit-icon {
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  flex-shrink: 0;
  pointer-events: none;
  transition: opacity var(--transition-hover);
}
.tab:hover .tab__edit-icon { opacity: 0.5; pointer-events: auto; }
.tab__edit-icon:hover { opacity: 1 !important; }
.tab--delete-mode .tab__edit-icon { display: none; }

/* Delete mode: light red background */
.tab--delete-mode {
  background: #F2DAD5 !important;
  opacity: 1 !important;
}
[data-theme="dark"] .tab--delete-mode {
  background: rgba(192, 57, 43, 0.2) !important;
}
.tab--delete-mode:hover {
  opacity: 1 !important;
}
.tab--delete-mode::after { display: none; }

/* Tab grid icon: match header line weight */
.tab__grid-icon rect {
  vector-effect: non-scaling-stroke;
  stroke-width: var(--header-line-w);
}

.tab__label {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: 4px;
}

/* DELETE label overlay on hover during delete mode */
.tab__delete-label {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: #C0392B;
  color: #fff;
  font-family: var(--font-body);
  font-size: calc(var(--size-header) * var(--scale));
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  cursor: pointer;
  border-radius: 0;
}
.tab--delete-mode:hover .tab__delete-label {
  display: flex;
}
.tab--delete-mode:hover .tab__label-input {
  opacity: 0;
}

/* Delete confirm menu */
.tab-delete-confirm {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 4px;
  padding: 4px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  z-index: 200;
  display: none;
  min-width: 90px;
  opacity: 1 !important;
}
.tab-delete-confirm--open {
  display: block;
}
.tab-delete-confirm__btn {
  display: block;
  width: 100%;
  padding: 4px 12px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: calc(var(--size-header) * var(--scale));
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  cursor: pointer;
  text-align: center;
}
.tab-delete-confirm__btn:hover {
  background: rgba(26, 26, 26, 0.05);
}
[data-theme="dark"] .tab-delete-confirm__btn:hover {
  background: rgba(232, 228, 222, 0.08);
}
.tab-delete-confirm__btn--delete {
  color: var(--accent);
}

.tab--add,
.tab--remove {
  border-right: none;
  font-size: calc(12px * var(--scale));
  font-weight: 300;
  opacity: 1;
  padding: 6px 10px;
  width: auto;
}
.tab--add {
  border-left: var(--header-line-w) solid var(--hairline);
}
.tab--add:hover,
.tab--remove:hover { opacity: 1; }
.tab--remove--active {
  opacity: 1 !important;
  color: var(--accent);
}

.top-bar__spacer { flex: 1; }

.top-bar__clock {
  font-variant-numeric: tabular-nums lining-nums;
  padding: 6px 12px;
  border-left: var(--header-line-w) solid var(--hairline);
  flex-shrink: 0;
}

.top-bar__settings-btn {
  background: var(--text);
  border: none;
  border-left: var(--header-line-w) solid var(--hairline);
  color: var(--bg);
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition-interactive);
}
.top-bar__settings-btn:hover { opacity: 1; }

.settings-arrow {
  font-size: calc(14px * var(--scale));
  font-weight: 300;
  line-height: 1;
  display: inline-block;
  color: var(--bg);
}

/* --- Main Area --- */
.main-area {
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* --- Views --- */
.view {
  position: absolute;
  inset: 0;
  display: none;
  overflow: auto;
}

.view--active {
  display: grid;
}

/* --- Dashboard Grid (Home) --- */
.grid-main {
  overflow: hidden;
  min-height: 0;
  gap: 20px;
  padding: 20px;
  justify-content: center;
  align-content: start;
  grid-auto-rows: 1fr;
}

.grid-main[data-cols="3"] { grid-template-columns: repeat(3, 1fr); }
.grid-main[data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
.grid-main[data-cols="1"] { grid-template-columns: repeat(1, 1fr); }

.grid-main[data-cols="4"] { grid-template-columns: repeat(4, 1fr); }
.grid-main[data-cols="5"] { grid-template-columns: repeat(5, 1fr); }

.grid-main[data-rows="1"] { grid-template-rows: repeat(1, 1fr); }
.grid-main[data-rows="2"] { grid-template-rows: repeat(2, 1fr); }
.grid-main[data-rows="3"] { grid-template-rows: repeat(3, 1fr); }
.grid-main[data-rows="4"] { grid-template-rows: repeat(4, 1fr); }

.widget {
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  transition: opacity 350ms ease, transform 300ms ease, box-shadow 300ms ease;
  position: relative;
}

/* Hidden (closed) widget */
.widget--closed { display: none; }

/* Maximized widget */
.widget--maximized {
  position: fixed !important;
  inset: 32px 0 24px 0;
  z-index: 50;
  border-radius: 0;
  border: none;
  background: var(--bg);
  grid-column: auto !important;
  grid-row: auto !important;
}

/* Maximized widget always full opacity */
.widget--maximized { opacity: 1 !important; }

/* --- Widget Title Bar (OS-style) --- */
.widget__titlebar {
  display: flex;
  align-items: center;
  padding: 6px var(--pad-widget);
  border-bottom: var(--hairline-w) solid var(--hairline);
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
  gap: 8px;
  min-height: 28px;
  background: rgba(26, 26, 26, var(--header-bg-opacity));
  transition: background var(--transition-speed);
}
[data-theme="dark"] .widget__titlebar {
  background: rgba(232, 228, 222, var(--header-bg-opacity));
}
.widget__titlebar:active { cursor: grabbing; }

/* Traffic light dots — only red close */
.widget__dots {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

.widget__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: var(--hairline-w) solid var(--hairline);
  background: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: background var(--transition-interactive), border-color var(--transition-interactive);
}

/* Show inner icons on titlebar hover */
.widget__dots .widget__dot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity var(--transition-interactive);
}
.widget__titlebar:hover .widget__dot svg {
  opacity: 1;
}

/* Dot colors on titlebar hover — only red close */
.widget__titlebar:hover .widget__dot--close {
  background: #FF5F57;
  border-color: #E04440;
}
.widget__dot:hover { transform: scale(1.15); }

.widget__title {
  font-size: calc(var(--size-header) * var(--scale));
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  line-height: 1.2;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget__badge { color: var(--accent); font-weight: 400; }
.widget__sub { font-weight: 300; text-transform: none; letter-spacing: 0; opacity: 0.6; }

/* Widget body (content below titlebar) */
.widget__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: var(--pad-widget);
}

/* Focus widget body is centered */
.widget--focus .widget__body {
  align-items: center;
  justify-content: center;
}

/* Drag placeholder */
.widget--drag-placeholder {
  border: 1px dashed var(--hairline);
  background: transparent;
  opacity: 0.3 !important;
  pointer-events: none;
}

/* Dragging state */
.widget--dragging {
  opacity: 0.85 !important;
  z-index: 60;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  pointer-events: none;
  transition: none;
}

/* iPhone-style wobble animation */
@keyframes wobble {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-0.7deg); }
  75% { transform: rotate(0.7deg); }
  100% { transform: rotate(0deg); }
}
.widget--wobble {
  animation: wobble 0.25s ease-in-out infinite;
}

/* --- Minimize Dock --- */
.minimize-dock {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 4px 12px;
  z-index: 30;
  background: var(--bg);
  border: var(--hairline-w) solid var(--hairline);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  max-width: 80%;
  overflow-x: auto;
}
.minimize-dock:empty { display: none; }

.dock-item {
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: calc(var(--size-secondary) * var(--scale));
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 8px;
  cursor: pointer;
  opacity: 0.5;
  white-space: nowrap;
  transition: opacity var(--transition-interactive);
}
.dock-item:hover { opacity: 1; }

/* --- Settings Panel (Slide-out) — Inverted (black bg, white text) --- */
.settings-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--settings-width);
  background: #1A1A1A;
  color: #E8E4DE;
  border-left: 0.5px solid rgba(232, 228, 222, 0.15);
  transform: translateX(100%);
  transition: transform var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

[data-theme="dark"] .settings-panel {
  background: #F5F1EB;
  color: #1A1A1A;
  border-left-color: rgba(26, 26, 26, 0.15);
}

.settings-panel--open {
  transform: translateX(0);
}

.settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pad-widget);
  border-bottom: 0.5px solid rgba(232, 228, 222, 0.15);
  flex-shrink: 0;
}

[data-theme="dark"] .settings-panel__header {
  border-bottom-color: rgba(26, 26, 26, 0.15);
}

.settings-panel__header .widget__title { margin-bottom: 0; color: inherit; }

.settings-panel__close {
  background: none;
  border: none;
  color: #E8E4DE;
  cursor: pointer;
  padding: 4px;
  opacity: 0.4;
  transition: opacity var(--transition-interactive);
}
[data-theme="dark"] .settings-panel__close { color: #1A1A1A; }
.settings-panel__close:hover { opacity: 1; }

.settings-panel__body {
  padding: var(--pad-widget);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-size: calc(var(--size-secondary) * var(--scale));
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.5;
  color: inherit;
}

.setting-toggle { display: flex; gap: 6px; }

.toggle-btn {
  background: none;
  border: 0.5px solid rgba(232, 228, 222, 0.25);
  color: #E8E4DE;
  font-family: var(--font-body);
  font-size: calc(var(--size-body) * var(--scale));
  padding: 4px 12px;
  cursor: pointer;
  transition: border-color var(--transition-interactive), opacity var(--transition-interactive);
  opacity: 0.4;
}
[data-theme="dark"] .toggle-btn {
  border-color: rgba(26, 26, 26, 0.25);
  color: #1A1A1A;
}
.toggle-btn.active { border-color: #E8E4DE; opacity: 1; }
[data-theme="dark"] .toggle-btn.active { border-color: #1A1A1A; }
.toggle-btn:hover { opacity: 0.7; }

.setting-slider { display: flex; align-items: center; gap: 8px; }
.slider-label { font-size: calc(var(--size-secondary) * var(--scale)); opacity: 0.5; user-select: none; color: inherit; }
.slider-label--lg { font-size: calc(13px * var(--scale)); }

.braun-slider { flex: 1; height: 24px; position: relative; cursor: grab; display: flex; align-items: center; }
.braun-slider:active { cursor: grabbing; }
.braun-slider__track { width: 100%; height: 1px; background: #E8E4DE; opacity: 0.2; }
[data-theme="dark"] .braun-slider__track { background: #1A1A1A; }
.braun-slider__handle {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid #E8E4DE; background: #1A1A1A;
  top: 50%; transform: translate(-50%, -50%); left: 20%;
  transition: background var(--transition-interactive); cursor: grab;
}
[data-theme="dark"] .braun-slider__handle {
  border-color: #1A1A1A; background: #F5F1EB;
}
.braun-slider__handle:active { cursor: grabbing; }

.braun-power {
  background: none; border: none; color: #E8E4DE; cursor: pointer; padding: 0;
  display: flex; align-items: center; transition: opacity var(--transition-interactive);
}
[data-theme="dark"] .braun-power { color: #1A1A1A; }
.braun-power:hover { opacity: 0.6; }
.power-ring { transition: fill var(--transition-speed); fill: none; }
[data-theme="dark"] .power-ring { fill: #1A1A1A; }

.accent-picker { display: flex; gap: 8px; }
.accent-dot {
  width: 12px; height: 12px; border-radius: 50%; border: 1px solid transparent;
  cursor: pointer; padding: 0;
  transition: border-color var(--transition-interactive), transform var(--transition-interactive);
}
.accent-dot:hover { transform: scale(1.2); }
.accent-dot--red { background: #C0392B; }
.accent-dot--orange { background: #D35400; }
.accent-dot--black { background: #1A1A1A; }
[data-theme="dark"] .accent-dot--black { background: #E8E4DE; }
.accent-dot.active { border-color: #E8E4DE; }
[data-theme="dark"] .accent-dot.active { border-color: #1A1A1A; }

.braun-switch { background: none; border: none; cursor: pointer; padding: 0; display: flex; align-items: center; }
.braun-switch__track {
  width: 32px; height: 12px; border: 0.5px solid #E8E4DE;
  position: relative; opacity: 0.3; transition: opacity var(--transition-interactive);
}
[data-theme="dark"] .braun-switch__track { border-color: #1A1A1A; }
.braun-switch.active .braun-switch__track { opacity: 1; }
.braun-switch__thumb {
  width: 10px; height: 10px; background: #E8E4DE;
  position: absolute; top: 50%; left: 1px; transform: translateY(-50%);
  transition: left var(--transition-interactive);
}
[data-theme="dark"] .braun-switch__thumb { background: #1A1A1A; }
.braun-switch.active .braun-switch__thumb { left: calc(100% - 11px); }

/* Line intensity indicator */
.line-intensity-label {
  font-size: calc(var(--size-secondary) * var(--scale));
  opacity: 0.4;
  font-variant-numeric: tabular-nums;
  width: 24px;
  text-align: center;
}

/* --- Scrollbar --- */
.settings-panel::-webkit-scrollbar { width: 2px; }
.settings-panel::-webkit-scrollbar-track { background: transparent; }
.settings-panel::-webkit-scrollbar-thumb { background: rgba(232, 228, 222, 0.2); }
[data-theme="dark"] .settings-panel::-webkit-scrollbar-thumb { background: rgba(26, 26, 26, 0.2); }

/* === VAULT — File Browser === */
.vault-search {
  width: 100%; background: none; border: none;
  border-bottom: var(--hairline-w) solid var(--hairline);
  color: var(--text); font-family: var(--font-body);
  font-size: calc(var(--size-body) * var(--scale)); padding: 4px 0; outline: none;
  margin-bottom: var(--gap-item); flex-shrink: 0;
  transition: border-color var(--transition-interactive);
}
.vault-search:focus { border-color: var(--text); }
.vault-search::placeholder { color: var(--text); opacity: 0.3; }

.vault-list { list-style: none; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.vault-list::-webkit-scrollbar { width: 2px; }
.vault-list::-webkit-scrollbar-track { background: transparent; }
.vault-list::-webkit-scrollbar-thumb { background: var(--hairline); }

.vault-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 3px 0; border-bottom: var(--hairline-w) solid var(--hairline);
  font-size: calc(var(--size-body) * var(--scale)); cursor: pointer;
  transition: opacity var(--transition-interactive);
}
.vault-item:hover { opacity: 0.6; }
.vault-item:last-child { border-bottom: none; }
.vault-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; order: -1; }
.vault-num {
  font-family: var(--font-mono);
  font-size: calc(var(--size-secondary) * var(--scale));
  opacity: 0.35;
  margin-left: auto;
  flex-shrink: 0;
}
.vault-tag { font-size: calc(8px * var(--scale)); opacity: 0.4; margin-left: 4px; flex-shrink: 0; }
.vault-arrow { opacity: 0.3; margin-left: 4px; flex-shrink: 0; font-size: calc(var(--size-secondary) * var(--scale)); }

.vault-item--open .vault-title { font-weight: 500; }
.vault-open-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--text); opacity: 0.5; flex-shrink: 0; margin-right: 4px;
}

.vault-new-btn {
  background: none; border: none; color: var(--text); font-family: var(--font-body);
  font-size: calc(var(--size-secondary) * var(--scale)); cursor: pointer;
  opacity: 0.4; padding: 4px 0; text-align: left;
  transition: opacity var(--transition-interactive); flex-shrink: 0;
  margin-top: 4px;
}
.vault-new-btn:hover { opacity: 0.7; }

/* === NOTO Editor === */
.widget--noto .widget__body {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.noto-title-bar {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
}

.noto-title-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
  cursor: text;
}

.noto-num {
  font-family: var(--font-mono);
  font-size: calc(var(--size-secondary) * var(--scale));
  opacity: 0.35;
  flex-shrink: 0;
  margin-left: auto;
}

/* Share-a-Noto button */
.noto-share-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  opacity: 0.35;
  transition: opacity 0.15s ease, transform 0.15s ease;
  color: var(--fg);
  margin-left: 4px;
}
.noto-share-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}
.noto-share-btn--loading {
  opacity: 0.3 !important;
  pointer-events: none;
  animation: noto-share-pulse 0.8s ease infinite;
}
@keyframes noto-share-pulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.5; }
}

/* Share toast notification */
.share-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--fg);
  color: var(--bg);
  font-family: var(--font-main);
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 8px 18px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}
.share-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.share-toast--error {
  background: #C0392B;
  color: #fff;
}

.noto-editor {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
}
.noto-editor::-webkit-scrollbar { width: 2px; }
.noto-editor::-webkit-scrollbar-track { background: transparent; }
.noto-editor::-webkit-scrollbar-thumb { background: var(--hairline); }

.noto-line {
  display: flex;
  align-items: flex-start;
  min-height: calc(var(--size-body) * var(--scale) * 1.6);
  border-bottom: var(--hairline-w) solid transparent;
  position: relative;
}


.noto-gutter {
  width: 28px;
  min-width: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  cursor: pointer;
  opacity: 0.25;
  padding: 2px 0;
  user-select: none;
  border-right: var(--hairline-w) solid transparent;
  transition: opacity var(--transition-interactive);
  color: var(--text);
}
.noto-gutter svg {
  display: block;
  flex-shrink: 0;
}
.noto-gutter:hover {
  opacity: 0.85;
  border-right-color: var(--hairline);
}
.noto-gutter--has-marker {
  opacity: 0.85;
}

.noto-gutter--color-dot {
  opacity: 1;
}

.noto-line-text {
  flex: 1;
  min-width: 0;
  outline: none;
  padding: 2px 8px;
  font-size: calc(var(--size-body) * var(--scale));
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: var(--font-body);
  color: var(--text);
}


/* Checked lines: strikethrough */
.noto-line--checked .noto-line-text {
  text-decoration: line-through;
  opacity: 0.4;
}
/* Bold / Italic / Size line styles */
.noto-line--bold .noto-line-text {
  font-weight: 700;
}
.noto-line--italic .noto-line-text {
  font-style: italic;
}
.noto-line--size-md .noto-line-text {
  font-size: calc(var(--size-body) * var(--scale) * 1.25);
}
.noto-line--size-lg .noto-line-text {
  font-size: calc(var(--size-body) * var(--scale) * 1.55);
}

/* Cross-links */
.noto-crosslink {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
  opacity: 0.7;
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.noto-crosslink:hover {
  opacity: 1;
  color: var(--accent);
}

/* Line Drag & Drop */
.noto-line--drag-origin {
  opacity: 0.25;
  background: rgba(26, 26, 26, 0.03);
  border-radius: 2px;
}
[data-theme="dark"] .noto-line--drag-origin {
  background: rgba(232, 228, 222, 0.03);
}
.noto-drag-ghost {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 6px;
  background: var(--bg, #F5F1EB);
  border: 1px solid rgba(26, 26, 26, 0.15);
  border-radius: 3px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
  font-family: var(--font-body, Helvetica, sans-serif);
  font-size: calc(var(--size-body, 11px) * var(--scale, 1));
  line-height: 1.5;
  color: var(--text, #1A1A1A);
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.noto-drag-ghost__marker {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  opacity: 0.7;
}
.noto-drag-ghost__marker svg {
  display: block;
}
.noto-drag-ghost__text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.noto-drag-indicator {
  position: fixed;
  z-index: 290;
  pointer-events: none;
  height: 2px;
  background: #C0392B;
  border-radius: 1px;
  display: none;
}
/* Prevent text selection and set grab cursor during line drag */
body.noto-line-dragging {
  cursor: grabbing !important;
  user-select: none;
}
body.noto-line-dragging * {
  cursor: grabbing !important;
}
/* Make gutter indicate it's draggable */
.noto-gutter {
  cursor: grab;
}

/* Marker Picker popover */
.marker-picker {
  position: fixed;
  z-index: 200;
  display: none;
  background: var(--bg);
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 4px;
  padding: 3px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  gap: 1px;
  flex-wrap: wrap;
  /* 5 dots × 28px + 4×1px gap + 6px padding = 150px + rounding buffer */
  width: 156px;
}
.marker-picker--open {
  display: flex;
}
.marker-picker__sep {
  width: 100%;
  height: 0;
  border-top: var(--hairline-w) solid var(--hairline);
  opacity: 0.3;
  margin: 2px 0;
}
.marker-picker__btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 3px;
  transition: background var(--transition-hover);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.marker-picker__btn:hover {
  background: rgba(26, 26, 26, 0.08);
}
[data-theme="dark"] .marker-picker__btn:hover {
  background: rgba(232, 228, 222, 0.08);
}
/* Style row for bold/italic/size */
.marker-picker__style-row {
  display: flex;
  width: 100%;
  gap: 2px;
}
.marker-picker__style-btn {
  background: none;
  border: 1px solid var(--hairline);
  color: var(--text);
  cursor: pointer;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  height: 24px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: opacity var(--transition-hover), background var(--transition-hover);
  font-family: var(--font-body);
}
.marker-picker__style-btn--italic {
  font-style: italic;
}
.marker-picker__style-btn:hover { opacity: 0.8; }
.marker-picker__style-btn--active {
  opacity: 1;
  background: rgba(26, 26, 26, 0.08);
}
[data-theme="dark"] .marker-picker__style-btn--active {
  background: rgba(232, 228, 222, 0.08);
}
.marker-picker__size-btn {
  background: none;
  border: 1px solid var(--hairline);
  color: var(--text);
  cursor: pointer;
  border-radius: 3px;
  height: 24px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: opacity var(--transition-hover), background var(--transition-hover);
  font-family: var(--font-body);
  font-size: 10px;
}
.marker-picker__size-btn--md { font-size: 12px; }
.marker-picker__size-btn--lg { font-size: 14px; }
.marker-picker__size-btn:hover { opacity: 0.8; }
.marker-picker__size-btn--active {
  opacity: 1;
  background: rgba(26, 26, 26, 0.08);
}
[data-theme="dark"] .marker-picker__size-btn--active {
  background: rgba(232, 228, 222, 0.08);
}

/* --- FOCUS --- */
.widget--focus { position: relative; z-index: 1; }

/* Focus mode: dim ALL widgets except the focus widget */
.focus-active .widget:not(.widget--focus) {
  opacity: 0.15;
}
/* During focus: hovering a non-focus widget restores it */
.focus-active .widget:not(.widget--focus):hover {
  opacity: 0.7;
}
/* Focus widget stays fully visible */
.focus-active .widget--focus {
  opacity: 1 !important;
}

/* During focus: dim top and bottom bars */
.focus-active .top-bar {
  opacity: 0.2;
  transition: opacity 350ms ease;
}
.focus-active .bottom-bar {
  opacity: 0.2;
  transition: opacity 350ms ease;
}

/* Focus widget stays normal during focus mode */
.widget--focus.focus--running {
  background: var(--bg);
}
.focus-timer { position: relative; width: 80%; max-width: 120px; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.focus-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.focus-ring__progress { stroke-dasharray: 263.9; stroke-dashoffset: 0; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset 1s linear; }
.focus-time { font-size: calc(var(--size-focus) * var(--scale)); font-weight: 300; font-variant-numeric: tabular-nums lining-nums; z-index: 1; }
.focus-btn {
  background: none; border: none; color: var(--text); font-family: var(--font-body);
  font-size: calc(var(--size-body) * var(--scale)); text-decoration: underline;
  cursor: pointer; margin-top: 8px; padding: 2px 8px;
  transition: opacity var(--transition-interactive);
}
.focus-btn:hover { opacity: 0.6; }
.focus-session { font-size: calc(var(--size-secondary) * var(--scale)); font-weight: 300; opacity: 0.4; margin-top: 4px; }

/* --- WEATHER --- */
.weather-current { display: flex; align-items: center; gap: 12px; margin-bottom: var(--gap-item); flex-shrink: 0; }
.weather-temp { font-size: calc(var(--size-temp) * var(--scale)); font-weight: 300; }
.weather-details { font-size: calc(var(--size-secondary) * var(--scale)); font-weight: 300; opacity: 0.6; display: flex; flex-direction: column; gap: 2px; }
.weather-forecast { display: flex; gap: 0; flex: 1; }
.forecast-day {
  flex: 1; text-align: center; font-size: calc(var(--size-secondary) * var(--scale));
  font-weight: 300; border-right: var(--hairline-w) solid var(--hairline);
  padding: 4px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.forecast-day:last-child { border-right: none; }
.forecast-day__name { text-transform: uppercase; letter-spacing: 1px; opacity: 0.5; }
.forecast-day__temps { opacity: 0.7; }

/* --- MARKETS --- */
.markets-list { list-style: none; flex: 1; overflow: hidden; }
.market-item {
  display: flex; align-items: center; gap: 8px; padding: 3px 0;
  border-bottom: var(--hairline-w) solid var(--hairline);
  font-size: calc(var(--size-body) * var(--scale));
}
.market-item:last-child { border-bottom: none; }
.market-ticker { font-weight: 500; width: 36px; flex-shrink: 0; }
.market-price { flex: 1; font-variant-numeric: tabular-nums lining-nums; }
.market-change { font-size: calc(var(--size-secondary) * var(--scale)); font-variant-numeric: tabular-nums lining-nums; flex-shrink: 0; width: 60px; text-align: right; }
.market-change--up { color: var(--accent); }
.market-change--down { opacity: 0.5; }
.market-spark { flex-shrink: 0; }

/* --- TRACKED --- */
.tracked-list { list-style: none; flex: 1; overflow: hidden; }
.tracked-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: calc(var(--size-body) * var(--scale)); }
.tracked-cat { width: 48px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracked-time { font-size: calc(var(--size-secondary) * var(--scale)); font-weight: 300; width: 44px; flex-shrink: 0; opacity: 0.6; }
.tracked-bar-wrap { flex: 1; height: 4px; background: var(--hairline); min-width: 0; }
.tracked-bar { height: 100%; background: var(--text); opacity: 0.5; transition: width 0.3s ease; }
.tracked-add {
  background: none; border: none; color: var(--text); font-family: var(--font-body);
  font-size: calc(var(--size-secondary) * var(--scale)); cursor: pointer;
  opacity: 0.4; padding: 4px 0; text-align: left;
  transition: opacity var(--transition-interactive); flex-shrink: 0;
}
.tracked-add:hover { opacity: 0.7; }
.tracked-input-row { display: flex; gap: 4px; flex-shrink: 0; padding-top: 4px; }
.tracked-input-row.hidden { display: none; }
.tracked-input {
  flex: 1; background: none; border: none;
  border-bottom: var(--hairline-w) solid var(--hairline);
  color: var(--text); font-family: var(--font-body);
  font-size: calc(var(--size-secondary) * var(--scale)); padding: 2px 0; outline: none;
}
.tracked-input:focus { border-color: var(--text); }
.tracked-save {
  background: none; border: none; color: var(--text); font-family: var(--font-body);
  font-size: calc(var(--size-secondary) * var(--scale)); cursor: pointer;
  text-decoration: underline; transition: opacity var(--transition-interactive);
}
.tracked-save:hover { opacity: 0.6; }

/* --- Bottom Bar --- */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--pad-widget);
  border-top: var(--hairline-w) solid var(--hairline);
  font-size: calc(var(--size-secondary) * var(--scale));
  color: var(--text);
  opacity: 0.5;
  min-height: 28px;
}
.bottom-bar__center {
  font-weight: 300;
}
.bottom-bar__right {
  color: var(--text); text-decoration: none;
  transition: opacity var(--transition-interactive);
}
.bottom-bar__right:hover { opacity: 0.6; }

/* --- Selection --- */
::selection { background: var(--accent); color: var(--bg); }

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

/* --- Drag Flicker Fix --- */
.grid-main--dragging {
  gap: 0 !important;
  padding: 10px !important;
}
.grid-main--dragging .widget,
.grid-main--dragging .widget--drag-placeholder {
  margin: 10px;
}

/* --- Grid Size Picker --- */
.grid-picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
}

.grid-picker-overlay--open {
  display: block;
}

.grid-picker {
  position: absolute;
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 4px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.grid-picker__item {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  border-radius: 3px;
  opacity: 0.5;
  transition: opacity var(--transition-hover), background var(--transition-hover);
}

.grid-picker__item:hover {
  opacity: 1;
  background: rgba(26, 26, 26, 0.05);
}

[data-theme="dark"] .grid-picker__item:hover {
  background: rgba(232, 228, 222, 0.08);
}

.grid-picker__sep {
  width: 0;
  border-left: var(--hairline-w) solid var(--hairline);
  align-self: stretch;
  margin: 4px 4px;
  opacity: 0.3;
}

.grid-picker__preset {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 3px;
  opacity: 0.5;
  font-family: var(--font-body);
  font-size: calc(8px * var(--scale));
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: opacity var(--transition-hover), background var(--transition-hover);
}
.grid-picker__preset:hover {
  opacity: 1;
  background: rgba(26, 26, 26, 0.05);
}
[data-theme="dark"] .grid-picker__preset:hover {
  background: rgba(232, 228, 222, 0.08);
}

/* --- Widget Placeholder (Custom Tabs) --- */
.widget-placeholder {
  border: 1px dashed var(--hairline);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  opacity: 0.35;
  transition: opacity var(--transition-hover);
}

.widget-placeholder:hover {
  opacity: 0.6;
}

.widget-placeholder__add {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  opacity: 0.5;
}

.widget-placeholder__add:hover {
  opacity: 1;
}

/* --- Widget Selector (Popover) --- */
.widget-selector-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
}

.widget-selector-overlay--open {
  display: block;
}

.widget-selector {
  position: absolute;
  background: var(--bg);
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 4px;
  padding: 4px 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  min-width: 180px;
  max-height: 320px;
  overflow-y: auto;
}

.widget-selector__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 12px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: calc(var(--size-body) * var(--scale));
  cursor: pointer;
  text-align: left;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.widget-selector__item:hover {
  background: rgba(26, 26, 26, 0.05);
}

[data-theme="dark"] .widget-selector__item:hover {
  background: rgba(232, 228, 222, 0.08);
}

.widget-selector__sep {
  height: 0;
  border-top: var(--hairline-w) solid var(--hairline);
  margin: 4px 12px;
  opacity: 0.3;
}

.widget-selector__item--new-noto {
  font-weight: 500;
  color: var(--accent);
}

.widget-selector__noto-num {
  font-family: var(--font-mono);
  font-size: calc(var(--size-secondary) * var(--scale));
  opacity: 0.35;
  margin-left: auto;
  flex-shrink: 0;
}
.widget-selector__noto-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Sort bar */
.widget-selector__sort-bar {
  display: flex;
  gap: 2px;
  padding: 2px 12px 4px;
  border-bottom: var(--hairline-w) solid var(--hairline);
  margin-bottom: 2px;
}
.widget-selector__sort-btn {
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: calc(var(--size-secondary) * var(--scale));
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  opacity: 0.35;
  transition: opacity var(--transition-hover);
}
.widget-selector__sort-btn:hover { opacity: 0.7; }
.widget-selector__sort-btn--active { opacity: 1; font-weight: 500; }

/* Grid matrix picker */
.grid-matrix-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
}
.grid-matrix-overlay--open { display: block; }
.grid-matrix {
  position: absolute;
  background: var(--bg);
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  z-index: 111;
}
.grid-matrix__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.grid-matrix__cell {
  width: 28px;
  height: 22px;
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 2px;
  background: none;
  cursor: pointer;
  transition: background 80ms ease, border-color 80ms ease;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.grid-matrix__cell:hover,
.grid-matrix__cell--highlight {
  background: rgba(211,84,0,0.12);
  border-color: #D35400;
}
.grid-matrix__label {
  text-align: center;
  font-size: calc(var(--size-secondary) * var(--scale));
  opacity: 1;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  letter-spacing: 0;
}

/* --- Custom Tab View --- */
.custom-tab-view {
  justify-content: center;
  align-content: start;
}

/* --- Tab Grid Icon Wrapper & Submenu --- */
.tab__grid-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 2px;
}
.tab-grid-submenu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 150px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 100;
  pointer-events: auto;
}
.grid-control__slider-row {
  display: flex; align-items: center; gap: 8px;
}
.grid-control__slider-label {
  font-size: 9px; letter-spacing: 0.1em;
  width: 28px; flex-shrink: 0; opacity: 0.5;
}
.grid-control__slider-val {
  font-size: 10px; width: 14px; text-align: right; opacity: 0.7;
}
.grid-control__slider {
  flex: 1; position: relative; height: 24px; cursor: pointer;
}

/* --- Resize Overlay & Handles --- */
.resize-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.resize-handle {
  position: absolute;
  z-index: 10;
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: auto;
}
.resize-handle:hover { opacity: 1; }
.resize-handle--col {
  width: 20px; cursor: col-resize;
  transform: translateX(-50%);
}
.resize-handle--row {
  height: 20px; cursor: row-resize;
  transform: translateY(-50%);
}
.resize-handle--col::after {
  content: '';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 24px;
  background: var(--text); opacity: 0.3;
  border-radius: 1px;
}
.resize-handle--row::after {
  content: '';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 24px; height: 2px;
  background: var(--text); opacity: 0.3;
  border-radius: 1px;
}
body.resizing {
  cursor: col-resize !important;
  user-select: none;
}
body.resizing-row {
  cursor: row-resize !important;
  user-select: none;
}

/* Responsive: smaller screens */
@media (max-width: 1199px) {
  .grid-main[data-cols="3"] { grid-template-columns: repeat(2, 1fr); }
  .widget { grid-column: auto !important; grid-row: auto !important; }
}

@media (max-width: 799px) {
  .grid-main[data-cols="3"],
  .grid-main[data-cols="2"] { grid-template-columns: repeat(1, 1fr); }
}

/* Quick new-note dialog */
.quick-note-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: none; align-items: flex-start; justify-content: center;
  padding-top: 80px; background: rgba(0,0,0,0.04);
}
.quick-note-overlay--open { display: flex; }
.quick-note-dialog {
  background: var(--bg); border: var(--hairline-w) solid var(--text);
  padding: var(--pad-widget); min-width: 240px;
  display: flex; flex-direction: column; gap: 8px;
}
.quick-note-dialog__label {
  font-size: calc(var(--size-header) * var(--scale));
  font-weight: 500; text-transform: uppercase; letter-spacing: 1.5px;
}
.quick-note-dialog__input {
  width: 100%; background: none; border: none;
  border-bottom: var(--hairline-w) solid var(--hairline);
  color: var(--text); font-family: var(--font-body);
  font-size: calc(var(--size-body) * var(--scale)); padding: 4px 0; outline: none;
}
.quick-note-dialog__input:focus { border-color: var(--text); }
.quick-note-dialog__input::placeholder { color: var(--text); opacity: 0.3; }
.quick-note-dialog__hint {
  font-size: calc(var(--size-secondary) * var(--scale));
  opacity: 0.3; font-weight: 300;
}

/* --- Week View --- */
.view--active:has(.week-view) {
  display: block;
  overflow: hidden;
}

.week-view {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: 1fr;
  gap: 12px;
  padding: 12px;
  height: 100%;
}

/* Each day = a widget-style box */
.week-day {
  display: flex;
  flex-direction: column;
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 6px;
  overflow: hidden;
  min-width: 0;
}

.week-day--today {
  background: rgba(26, 26, 26, 0.02);
}
[data-theme="dark"] .week-day--today {
  background: rgba(232, 228, 222, 0.03);
}

/* Day header = widget titlebar style, no traffic lights */
.week-day__header {
  display: flex;
  align-items: center;
  padding: 6px var(--pad-widget);
  border-bottom: var(--hairline-w) solid var(--hairline);
  flex-shrink: 0;
  min-height: 28px;
  background: rgba(26, 26, 26, var(--header-bg-opacity));
  transition: background var(--transition-speed);
}
[data-theme="dark"] .week-day__header {
  background: rgba(232, 228, 222, var(--header-bg-opacity));
}

.week-day__title {
  font-size: calc(var(--size-header) * var(--scale));
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-day--today .week-day__title {
  font-weight: 600;
}

/* Timeline area (top) */
.week-day__timeline {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.week-hour {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  border-top: var(--hairline-w) solid var(--hairline);
  opacity: 0.25;
}

.week-hour__label {
  font-size: calc(7px * var(--scale));
  font-variant-numeric: tabular-nums;
  padding: 1px 4px 0;
  opacity: 0.7;
  flex-shrink: 0;
  line-height: 1;
}

/* Events placed on the timeline */
.week-event {
  position: absolute;
  left: 28px;
  right: 4px;
  font-size: calc(var(--size-secondary) * var(--scale));
  padding: 2px 5px;
  border-left: 2px solid var(--text);
  background: rgba(26, 26, 26, 0.04);
  border-radius: 0 3px 3px 0;
  line-height: 1.3;
  overflow: hidden;
  z-index: 1;
}
[data-theme="dark"] .week-event {
  background: rgba(232, 228, 222, 0.06);
}

.week-event__time {
  opacity: 0.5;
  font-variant-numeric: tabular-nums;
  display: inline;
  margin-right: 4px;
}

.week-event__title {
  display: inline;
}

.week-event--accent {
  border-left-color: var(--accent);
}

/* Tasks area (bottom, pinned) */
.week-day__tasks {
  flex-shrink: 0;
  border-top: var(--hairline-w) solid var(--hairline);
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.week-task {
  font-size: calc(var(--size-secondary) * var(--scale));
  padding: 2px 0;
  opacity: 0.6;
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1.3;
}

.week-task__check {
  width: calc(8px * var(--scale));
  height: calc(8px * var(--scale));
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 1px;
  flex-shrink: 0;
  margin-top: 1px;
}

.week-task--done {
  opacity: 0.25;
  text-decoration: line-through;
}

/* ============================================
   MOBILE — iPhone (max-width 479px)
   ============================================ */
@media (max-width: 479px) {

  html, body {
    height: auto;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dashboard {
    grid-template-rows: auto 1fr auto;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  /* --- Mobile Top Bar --- */
  .top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    padding: 0 10px;
    min-height: 44px;
  }

  .top-bar__date {
    font-size: calc(var(--size-secondary) * var(--scale));
    padding: 6px 8px;
  }

  /* Hide tabs on mobile — single column, no grid switching */
  .top-bar__tabs,
  .tab--add,
  .tab--remove {
    display: none !important;
  }

  .top-bar__spacer { flex: 1; }

  .top-bar__clock {
    font-size: calc(var(--size-secondary) * var(--scale));
    padding: 6px 8px;
  }

  /* --- Main Area: scrollable --- */
  .main-area {
    overflow: visible;
    min-height: 0;
  }

  .view {
    position: relative;
    inset: auto;
    overflow: visible;
  }

  .view--active {
    display: flex;
    flex-direction: column;
  }

  /* --- Grid: single column, stacked --- */
  .grid-main {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    overflow: visible;
    min-height: 0;
  }

  /* Widget sizing on mobile */
  .widget {
    min-height: 180px;
    max-height: none;
    grid-column: auto !important;
    grid-row: auto !important;
  }

  /* Specific widget heights for mobile */
  .widget--vault   { min-height: 200px; max-height: 260px; }
  .widget--noto    { min-height: 200px; max-height: 300px; }
  .widget--focus   { min-height: 200px; max-height: 240px; }
  .widget--weather { min-height: 180px; max-height: 220px; }
  .widget--markets { min-height: 180px; max-height: 220px; }
  .widget--tracked { min-height: 180px; max-height: 220px; }

  /* Maximized widget: full screen overlay */
  .widget--maximized {
    inset: 0;
    border-radius: 0;
    z-index: 90;
  }

  /* Touch-friendly titlebar */
  .widget__titlebar {
    min-height: 36px;
    padding: 8px var(--pad-widget);
    cursor: default;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .widget__dot {
    width: 14px;
    height: 14px;
  }

  /* --- Drag reorder visual feedback --- */
  .widget--mobile-dragging {
    position: fixed !important;
    z-index: 200 !important;
    opacity: 0.92;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    transform: scale(1.02);
    pointer-events: none;
    transition: none !important;
  }

  .widget--mobile-placeholder {
    border: var(--hairline-w) dashed var(--hairline) !important;
    background: rgba(26, 26, 26, 0.03) !important;
    border-radius: 6px;
    min-height: 60px;
    opacity: 0.5;
  }
  .widget--mobile-placeholder > * { visibility: hidden; }

  .widget--mobile-wobble {
    animation: mobileWobble 0.15s ease-in-out infinite alternate;
  }
  @keyframes mobileWobble {
    0%   { transform: rotate(-0.3deg); }
    100% { transform: rotate(0.3deg); }
  }

  /* --- Settings Panel: full-width overlay on mobile --- */
  .settings-panel {
    width: 100%;
    border-left: none;
  }

  .settings-panel__header {
    min-height: 44px;
  }

  /* Settings button: bigger touch target */
  .top-bar__settings-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* --- Minimize dock: horizontal scroll on mobile --- */
  .minimize-dock {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 12px;
  }

  /* --- Bottom Bar --- */
  .bottom-bar {
    padding: 6px 12px;
    min-height: 28px;
  }

  /* --- Grid Picker / Widget Selector: adapt for mobile --- */
  .grid-picker-overlay,
  .widget-selector-overlay {
    display: none !important;
  }

  /* --- Week view on mobile: stacked day cards --- */
  .week-view {
    display: flex !important;
    flex-direction: column;
    grid-template-columns: none;
    gap: 12px;
    padding: 12px;
    height: auto;
    overflow: visible;
  }

  .week-day {
    min-height: 120px;
  }

  .week-day__timeline {
    min-height: 200px;
  }

}

/* ============================================
   AUTH OVERLAY
   ============================================ */
.auth-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(26, 26, 26, 0.40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
}
.auth-overlay--open {
  display: flex;
}
.dashboard--blurred {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}
.auth-card {
  background: #F5F1EB;
  border: 1px solid rgba(26, 26, 26, 0.15);
  border-radius: 6px;
  padding: 40px 36px 32px;
  width: 320px;
  max-width: 92vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
[data-theme="dark"] .auth-card {
  background: #1A1A1A;
  border-color: rgba(245, 241, 235, 0.12);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
  user-select: none;
}
.auth-logo .logo-jp {
  display: block;
  font-size: 11px;
  letter-spacing: 0.3em;
  opacity: 0.35;
  margin-bottom: 2px;
}
.auth-logo .logo-latin {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.15em;
}
.auth-view {
  display: none;
}
.auth-view--active {
  display: block;
}
.auth-input {
  display: block;
  width: 100%;
  padding: 9px 11px;
  margin-bottom: 10px;
  background: transparent;
  border: 1px solid rgba(26, 26, 26, 0.20);
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  color: #1A1A1A;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.auth-input:focus {
  border-color: rgba(26, 26, 26, 0.50);
}
[data-theme="dark"] .auth-input {
  border-color: rgba(245, 241, 235, 0.18);
  color: #F5F1EB;
}
[data-theme="dark"] .auth-input:focus {
  border-color: rgba(245, 241, 235, 0.45);
}
.auth-input::placeholder {
  color: rgba(26, 26, 26, 0.35);
}
[data-theme="dark"] .auth-input::placeholder {
  color: rgba(245, 241, 235, 0.30);
}
.auth-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  background: #1A1A1A;
  color: #F5F1EB;
  border: none;
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: opacity 0.15s;
}
.auth-btn:hover {
  opacity: 0.85;
}
.auth-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
[data-theme="dark"] .auth-btn {
  background: #F5F1EB;
  color: #1A1A1A;
}
.auth-error {
  font-size: 10px;
  color: #C0392B;
  min-height: 0;
  overflow: hidden;
  transition: min-height 0.15s;
  margin-bottom: 0;
}
.auth-error--visible {
  min-height: 16px;
  margin-bottom: 4px;
}
.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  font-size: 10px;
}
.auth-links a {
  color: inherit;
  opacity: 0.45;
  text-decoration: none;
  transition: opacity 0.15s;
}
.auth-links a:hover {
  opacity: 0.75;
}
.auth-hint {
  font-size: 11px;
  opacity: 0.55;
  margin: 0 0 14px;
  line-height: 1.5;
}
.auth-skip {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 8px;
  background: none;
  border: 1px solid rgba(26, 26, 26, 0.10);
  border-radius: 3px;
  font-family: inherit;
  font-size: 10px;
  color: inherit;
  opacity: 0.40;
  cursor: pointer;
  transition: opacity 0.15s;
  letter-spacing: 0.05em;
}
.auth-skip:hover {
  opacity: 0.65;
}

/* ============================================
   SYNC STATUS & USER DISPLAY
   ============================================ */
.sync-status {
  font-size: 9px;
  letter-spacing: 0.05em;
  opacity: 0.40;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0 6px;
}
.sync-status--syncing {
  opacity: 0.55;
}
.sync-status--error {
  color: #C0392B;
  opacity: 0.75;
}
.sync-status--offline {
  opacity: 0.30;
}
.user-display {
  font-size: 9px;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.2s, max-width 0.3s;
  padding: 0;
  letter-spacing: 0.03em;
}
.user-display--visible {
  opacity: 0.45;
  max-width: 160px;
  padding: 0 4px;
}
.top-bar__logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.30;
  padding: 2px 4px;
  transition: opacity 0.15s;
}
.top-bar__logout-btn:hover {
  opacity: 0.65;
}
