:root {
  color-scheme: light;
  --bg: #e8edf3;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --surface-muted: #f2f5f8;
  --text: #15202b;
  --muted: #697684;
  --line: rgba(31, 42, 55, 0.13);
  --accent: #1677ff;
  --accent-soft: #e5f0ff;
  --danger: #d92d20;
  --shadow: 0 18px 45px rgba(20, 34, 50, 0.16);
  --radius: 13px;
  --topbar-height: 54px;
  --page-background: linear-gradient(135deg, #dce8f4 0%, #eef4ed 48%, #e6edf5 100%);
  --widget-gap: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151c;
  --surface: rgba(25, 31, 40, 0.94);
  --surface-solid: #1b222c;
  --surface-muted: #242d38;
  --text: #edf3f8;
  --muted: #a7b0bc;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #72adff;
  --accent-soft: #243b59;
  --danger: #ff7168;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  --page-background: linear-gradient(135deg, #121922 0%, #17201c 48%, #19222d 100%);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[contenteditable="true"]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 1px;
}

a {
  color: var(--accent);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 0 5px;
}

.login-screen {
  align-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(44, 133, 255, 0.2), transparent 35%),
    radial-gradient(circle at 80% 75%, rgba(78, 207, 136, 0.18), transparent 35%),
    #0d131a;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
}

.login-card {
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 22px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.42);
  color: #15202b;
  max-width: 440px;
  padding: 42px;
  width: 100%;
}

.login-card h1 {
  font-size: 34px;
  letter-spacing: -0.04em;
  margin: 0 0 8px;
}

.login-card form {
  display: grid;
  gap: 17px;
  margin-top: 0;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, #1677ff, #0848a2);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(22, 119, 255, 0.28);
  color: white;
  display: flex;
  font-size: 22px;
  font-weight: 900;
  height: 58px;
  justify-content: center;
  margin-bottom: 24px;
  width: 58px;
}

label {
  display: grid;
  font-weight: 650;
  gap: 7px;
}

input,
textarea,
select {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 9px;
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  min-height: 95px;
  resize: vertical;
}

.primary,
.secondary,
.danger-button,
.text-button {
  border: 0;
  border-radius: 9px;
  font-weight: 700;
  min-height: 40px;
  padding: 9px 14px;
}

.primary {
  background: var(--accent);
  color: white;
}

.secondary {
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.danger-button {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface-solid));
  color: var(--danger);
}

.text-button {
  background: transparent;
  color: var(--accent);
}

.wide {
  width: 100%;
}

.form-message {
  color: #bb251b;
  margin: 0;
  min-height: 20px;
}

.app-shell {
  height: 100vh;
  overflow: hidden;
}

.topbar {
  align-items: center;
  backdrop-filter: blur(22px);
  background: rgba(11, 17, 24, 0.9);
  color: white;
  display: flex;
  gap: 12px;
  height: var(--topbar-height);
  justify-content: space-between;
  padding: 7px 12px;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 30;
  transition: transform 180ms ease;
}

.topbar-left,
.topbar-actions,
.widget-actions,
.button-row,
.toolbar,
.inline-fields {
  align-items: center;
  display: flex;
  gap: 8px;
}

.topbar-left {
  min-width: 0;
  overflow: hidden;
}

.topbar-actions {
  flex-shrink: 0;
}

.topbar-divider {
  background: rgba(255, 255, 255, 0.28);
  height: 24px;
  margin: 0 2px;
  width: 1px;
}

.topbar-add-widget {
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 800;
}

.topbar-add-widget:hover {
  background: color-mix(in srgb, var(--accent) 82%, white);
}

.topbar-reveal-button {
  background: rgba(11, 17, 24, 0.9);
  border: 0;
  border-radius: 0 0 0 9px;
  color: white;
  font-size: 17px;
  height: 30px;
  position: fixed;
  right: 0;
  top: 0;
  width: 42px;
  z-index: 31;
}

.app-shell.topbar-collapsed .topbar {
  pointer-events: none;
  transform: translateY(calc(-100% - 1px));
}

.app-shell.topbar-collapsed .dashboard {
  padding-top: 18px;
}

.topbar-button,
.icon-button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  min-height: 36px;
}

.topbar-button {
  padding: 7px 11px;
  white-space: nowrap;
}

.topbar-button:hover,
.icon-button:hover {
  background: rgba(255, 255, 255, 0.13);
}

.topbar-button.strong {
  font-weight: 800;
}

.icon-button {
  align-items: center;
  display: inline-flex;
  font-size: 16px;
  justify-content: center;
  min-width: 36px;
  padding: 6px;
}

.count {
  background: var(--accent);
  border-radius: 20px;
  color: white;
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  margin-left: 5px;
  min-width: 19px;
  padding: 2px 5px;
  text-align: center;
}

.page-tabs {
  align-items: center;
  display: flex;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.page-tabs::-webkit-scrollbar {
  display: none;
}

.page-tabs.collapsed {
  display: none;
}

.page-tab {
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.72);
  max-width: 180px;
  overflow: hidden;
  padding: 8px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.page-tab.active {
  background: white;
  color: #17202a;
}

.dashboard {
  background-color: var(--bg);
  background-image: var(--page-background);
  background-position: center;
  background-size: cover;
  display: grid;
  gap: var(--widget-gap);
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  height: 100vh;
  overflow: auto;
  padding: calc(var(--topbar-height) + 18px) 18px 90px;
}

.dashboard-column {
  align-content: start;
  display: grid;
  gap: var(--widget-gap);
  min-width: 0;
}

.empty-column {
  align-items: center;
  border: 2px dashed color-mix(in srgb, var(--muted) 30%, transparent);
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  justify-content: center;
  min-height: 110px;
  padding: 20px;
}

.widget {
  align-self: start;
  background: var(--widget-color, var(--surface));
  border: 1px solid color-mix(in srgb, var(--line) calc(100% - var(--widget-transparency, 0%)), transparent);
  border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(22, 35, 49, 0.08);
  max-height: var(--widget-height, none);
  min-height: 120px;
  overflow: hidden;
  position: relative;
}

.widget::before {
  background: var(--surface-solid);
  content: "";
  inset: 0;
  opacity: calc(var(--widget-transparency, 0) / 100);
  pointer-events: none;
  position: absolute;
}

.widget > * {
  position: relative;
}

.widget-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 14px 14px 8px;
}

.widget-header h2 {
  font-size: 15px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-actions {
  opacity: 0;
  transition: opacity 120ms ease;
}

.widget:hover .widget-actions,
.widget:focus-within .widget-actions {
  opacity: 1;
}

.widget-actions .icon-button {
  background: color-mix(in srgb, var(--surface-solid) 65%, transparent);
  color: var(--text);
  min-height: 29px;
  min-width: 29px;
}

.widget-body {
  max-height: calc(var(--widget-height, 1000px) - 47px);
  overflow: auto;
  padding: 6px 14px 14px;
}

.widget-body:empty::after {
  color: var(--muted);
  content: "Nog leeg";
  display: block;
  padding: 14px 0;
}

.bookmark-grid {
  display: grid;
  gap: 13px 9px;
  grid-template-columns: repeat(auto-fill, minmax(var(--bookmark-width, 88px), 1fr));
}

.bookmark-grid.icon-small {
  --bookmark-width: 68px;
}

.bookmark-grid.icon-large {
  --bookmark-width: 108px;
}

.bookmark-card {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: start;
  min-width: 0;
  padding: 6px;
  text-decoration: none;
  width: 100%;
}

.bookmark-card:hover {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

.bookmark-icon {
  align-items: center;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex: 0 0 auto;
  font-size: 34px;
  height: 72px;
  justify-content: center;
  overflow: hidden;
  width: 72px;
}

.icon-small .bookmark-icon {
  border-radius: 11px;
  font-size: 24px;
  height: 48px;
  width: 48px;
}

.icon-large .bookmark-icon {
  border-radius: 20px;
  font-size: 45px;
  height: 92px;
  width: 92px;
}

.bookmark-icon img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.bookmark-title {
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
}

.bookmark-list,
.task-list,
.reading-mini-list,
.notes-stack,
.search-results {
  display: grid;
  gap: 7px;
}

.bookmark-row,
.task-row,
.drawer-item,
.search-result,
.list-card {
  align-items: center;
  background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  gap: 9px;
  min-width: 0;
  padding: 9px 10px;
}

.bookmark-row {
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.bookmark-row:hover,
.search-result:hover {
  background: var(--accent-soft);
}

.bookmark-row .mini-icon {
  align-items: center;
  display: flex;
  font-size: 20px;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.bookmark-detail {
  min-width: 0;
}

.bookmark-detail strong,
.bookmark-detail small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-detail small {
  color: var(--muted);
  margin-top: 2px;
}

.group-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
  overflow-x: auto;
}

.group-tab {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  white-space: nowrap;
}

.group-tab.active {
  background: var(--accent);
  color: white;
}

.notes-content {
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.notes-content img {
  height: auto;
  max-width: 100%;
}

.notes-content > :first-child {
  margin-top: 0;
}

.notes-content > :last-child {
  margin-bottom: 0;
}

.task-row {
  align-items: flex-start;
}

.task-row input[type="checkbox"] {
  flex: 0 0 auto;
  min-height: 18px;
  width: 18px;
}

.task-row.done .task-main {
  color: var(--muted);
  text-decoration: line-through;
}

.task-main {
  flex: 1;
  min-width: 0;
}

.task-meta {
  color: var(--muted);
  display: flex;
  font-size: 11px;
  gap: 7px;
  margin-top: 3px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.tag {
  background: var(--accent-soft);
  border: 0;
  border-radius: 20px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  padding: 3px 7px;
}

.metadata-grid {
  display: grid;
  gap: 7px;
  grid-template-columns: minmax(100px, 0.7fr) minmax(160px, 1.3fr) auto;
}

.priority-high {
  color: #c92419;
}

.priority-medium {
  color: #9b6600;
}

.progress-row {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
  margin-bottom: 10px;
}

.progress-bar {
  background: var(--line);
  border-radius: 20px;
  flex: 1;
  height: 7px;
  overflow: hidden;
}

.progress-bar span {
  background: var(--accent);
  display: block;
  height: 100%;
}

.clock-widget,
.date-widget {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100px;
  text-align: center;
}

.clock-time {
  font-size: clamp(34px, 5vw, 60px);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: -0.05em;
}

.clock-sub,
.date-sub {
  color: var(--muted);
  margin-top: 3px;
}

.date-day {
  font-size: 55px;
  font-weight: 800;
  line-height: 1;
}

.date-month {
  font-size: 18px;
  font-weight: 700;
  margin-top: 8px;
}

.quick-task {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.quick-task input {
  min-width: 0;
}

.quick-task button {
  flex: 0 0 auto;
}

.scrim {
  background: rgba(9, 15, 22, 0.58);
  inset: 0;
  position: fixed;
  z-index: 40;
}

.drawer {
  background: var(--surface-solid);
  bottom: 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  position: fixed;
  top: 0;
  width: min(380px, 95vw);
  z-index: 50;
}

.drawer-left {
  left: 0;
}

.drawer-right {
  right: 0;
}

.wide-drawer {
  width: min(560px, 95vw);
}

#reading-drawer {
  transition: width 180ms ease;
}

#reading-drawer.maximized {
  left: 18px;
  right: 18px;
  top: 18px;
  bottom: 18px;
  width: auto;
}

#reading-drawer.maximized #reading-list {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.drawer-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.drawer-header h2 {
  margin: 0;
}

.drawer-list,
.page-list {
  min-height: 0;
  overflow: auto;
}

.page-list {
  flex: 1;
}

.page-section-title {
  align-items: center;
  display: flex;
  font-size: 13px;
  font-weight: 800;
  justify-content: space-between;
  margin: 15px 5px 6px;
}

.page-list-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  padding: 9px 10px;
  text-align: left;
  width: 100%;
}

.page-list-row {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px;
}

.page-order-actions {
  display: flex;
  gap: 2px;
}

.page-order-actions .icon-button {
  min-height: 30px;
  min-width: 30px;
  padding: 3px;
}

.page-order-actions .icon-button:disabled {
  cursor: default;
  opacity: 0.25;
}

.page-list-item:hover,
.page-list-item.active {
  background: var(--accent-soft);
}

.drawer-list {
  display: grid;
  gap: 9px;
}

.drawer-item {
  align-items: flex-start;
  display: grid;
  grid-template-columns: 1fr auto;
}

.drawer-item-content {
  min-width: 0;
  overflow-wrap: anywhere;
}

.reading-expand {
  align-items: center;
  background: transparent;
  border: 0;
  display: flex;
  font: inherit;
  justify-content: space-between;
  padding: 3px 0;
  text-align: left;
  width: 100%;
}

.reading-details {
  display: grid;
  gap: 7px;
  margin-top: 9px;
  overflow-wrap: anywhere;
}

.drawer-item-actions {
  display: flex;
  gap: 3px;
}

.quick-add,
.reading-add {
  display: grid;
  gap: 9px;
}

.modal-backdrop {
  align-items: center;
  background: rgba(9, 15, 22, 0.62);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 80;
}

.modal {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  max-width: 700px;
  overflow: hidden;
  width: 100%;
}

.modal.large {
  max-width: 1000px;
}

.modal-header,
.modal-footer {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 16px 18px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
}

.modal-body {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-two {
  grid-column: 1 / -1;
}

.choice-grid,
.widget-type-grid,
.icon-picker {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.choice-card,
.widget-type-card,
.icon-choice {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px;
  text-align: left;
}

.choice-card:hover,
.widget-type-card:hover,
.icon-choice:hover,
.choice-card.selected,
.icon-choice.selected {
  border-color: var(--accent);
}

.widget-type-card strong,
.widget-type-card span {
  display: block;
}

.widget-type-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.icon-choice {
  font-size: 24px;
  text-align: center;
}

.rich-editor {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
  line-height: 1.55;
  min-height: 360px;
  overflow: auto;
  padding: 15px;
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.toolbar button {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 34px;
  padding: 6px 10px;
}

.section-box {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px;
}

.section-box h3 {
  font-size: 14px;
  margin: 0 0 10px;
}

.list-manager {
  display: grid;
  gap: 7px;
}

.list-manager-row {
  align-items: center;
  display: grid;
  gap: 7px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
}

.menu {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 235px;
  padding: 7px;
  position: fixed;
  z-index: 75;
}

.menu button {
  background: transparent;
  border: 0;
  border-radius: 7px;
  display: block;
  padding: 10px 11px;
  text-align: left;
  width: 100%;
}

.menu button:hover {
  background: var(--surface-muted);
}

.menu button.danger {
  color: var(--danger);
}

.menu hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 6px 4px;
}

.toast-root {
  bottom: 22px;
  display: grid;
  gap: 8px;
  pointer-events: none;
  position: fixed;
  right: 22px;
  z-index: 100;
}

.toast {
  animation: toast-in 180ms ease-out;
  background: #131b24;
  border-radius: 10px;
  box-shadow: var(--shadow);
  color: white;
  max-width: 360px;
  padding: 11px 14px;
}

.toast.error {
  background: #8f211a;
}

.search-results {
  margin-top: 14px;
}

.search-result {
  align-items: flex-start;
  background: var(--surface-muted);
  border: 1px solid transparent;
  cursor: pointer;
  display: grid;
  grid-template-columns: 90px 1fr;
  text-align: left;
  width: 100%;
}

.search-result-type {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-result > span:last-child strong,
.search-result > span:last-child small {
  display: block;
}

.search-result > span:last-child small {
  margin-top: 3px;
}

.backup-warning {
  background: #fff6cf;
  border: 1px solid #edd376;
  border-radius: 10px;
  color: #493a00;
  padding: 12px;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
  height: 32px;
  width: 32px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (max-width: 1100px) {
  .topbar-button {
    font-size: 0;
  }

  .topbar-button .count,
  .topbar-button.strong {
    font-size: 12px;
  }

  .dashboard {
    grid-template-columns: repeat(2, minmax(260px, 1fr)) !important;
  }

  #reading-drawer.maximized {
    inset: 0;
  }
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .login-card {
    padding: 28px;
  }

  .topbar {
    position: sticky;
  }

  .page-tabs,
  #collapse-tabs-button {
    display: none;
  }

  .dashboard {
    display: block;
    height: auto;
    min-height: calc(100vh - var(--topbar-height));
    overflow: visible;
    padding: 14px 12px 90px;
  }

  .dashboard-column {
    margin-bottom: 14px;
  }

  .form-grid.two-columns {
    grid-template-columns: 1fr;
  }

  .span-two {
    grid-column: auto;
  }

  .modal-backdrop {
    padding: 0;
  }

  .modal,
  .modal.large {
    border-radius: 0;
    height: 100vh;
    max-height: none;
    max-width: none;
  }
}
