:root {
  color-scheme: light dark;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-muted: #f0eee8;
  --text: #1b1b18;
  --text-muted: #5b594f;
  --accent: #2c5d63;
  --border: rgba(0, 0, 0, 0.1);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  --radius: 16px;
  --font-base: "Playfair Display", "Times New Roman", serif;
  --note-bg: #ffffff;
  --note-dot: rgba(44, 93, 99, 0.12);
}

.theme-dark,
html.theme-dark {
  color-scheme: dark;
  --bg: #10100f;
  --surface: #181816;
  --surface-muted: #1f1f1d;
  --text: #f3f1ea;
  --text-muted: #b8b5aa;
  --accent: #5da3a6;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  --note-bg: #181816;
  --note-dot: rgba(93, 163, 166, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-base);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

.app {
  position: relative;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns 0.2s ease;
}

.app[data-sidebar="collapsed"] {
  grid-template-columns: 0 minmax(0, 1fr);
}

.app__overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 16, 15, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.app__overlay[hidden] {
  display: none;
}

.app[data-sidebar="collapsed"] .sidebar {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.sidebar {
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px 24px;
  border-right: 1px solid var(--border);
  height: 100%;
  min-height: 0;
  transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, padding 0.2s ease;
  overflow: hidden;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar__title {
  font-size: 28px;
  margin: 0;
  letter-spacing: 0.04em;
}

.sidebar__controls,
.sidebar__search {
  display: flex;
}

.sidebar__controls {
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.sidebar__settings {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--text-muted);
}

.sidebar__settings:hover,
.sidebar__settings:focus-visible {
  color: var(--accent);
}
.sidebar__search input {
  width: 100%;
}

.sidebar__search[hidden] {
  display: none !important;
}

.drawer-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.drawer-toggle--in-editor {
  margin-right: 0;
}

.note-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 4px 12px;
}

.note-list::-webkit-scrollbar {
  width: 6px;
}

.note-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.note-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 16px;
  border: 1px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.note-card:hover,
.note-card:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: none;
}

.note-card:focus-visible {
  box-shadow: 0 0 0 3px rgba(44, 93, 99, 0.18);
}

.note-card__content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-card__title {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-card__preview {
  font-size: 13px;
  color: var(--text-muted);
  max-height: 36px;
  overflow: hidden;
}

.note-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.note-card__meta {
  font-size: 12px;
  color: var(--text-muted);
}

.note-card__delete {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.note-card__delete:hover,
.note-card__delete:focus-visible {
  color: var(--accent);
  background: rgba(44, 93, 99, 0.12);
  outline: none;
}

.note-card.is-active {
  border-color: var(--accent);
  background: rgba(44, 93, 99, 0.08);
}

body.theme-dark .note-card.is-active {
  background: rgba(93, 163, 166, 0.12);
}

.note-list__empty {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 12px;
}

.editor {
  display: flex;
  flex-direction: column;
  padding: 32px 48px;
  gap: 24px;
  background: var(--surface);
  min-height: 0;
  height: 100vh;
}

.editor__topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.editor__meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.editor__meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor__meta-row--stacked {
  justify-content: space-between;
  width: 100%;
  align-items: center;
}

#note-title {
  border: none;
  background: transparent;
  font-size: 28px;
  font-weight: 600;
  padding: 0;
  color: inherit;
  outline: none;
  flex: 1;
  min-width: 0;
}

.editor__timestamp {
  color: var(--text-muted);
  font-size: 13px;
}

.editor__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.control {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.control--font {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: inherit;
  flex: 1 1 260px;
}

.control--font span:first-child {
  color: var(--text-muted);
}

.control--timer span:first-child {
  color: var(--text-muted);
  font-size: 14px;
}

.control input[type="range"] {
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
}

.control__value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  min-width: 44px;
  text-align: right;
  margin-left: 12px;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease, color 0.2s ease;
  padding: 0;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: rgba(44, 93, 99, 0.12);
}

.icon-btn--theme {
  border-radius: 50%;
}

.icon {
  width: 20px;
  height: 20px;
  display: block;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.icon--pause {
  display: none;
}

.icon--drawer {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon--gear {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.icon--close {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
}

.icon--close path {
  stroke: currentColor;
}

.icon--moon {
  display: none;
}

body.theme-dark .icon--sun {
  display: none;
}

body.theme-dark .icon--moon {
  display: block;
}

.editor__body {
  flex: 1;
  display: flex;
  min-height: 0;
}

#note-content {
  width: 100%;
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: 18px;
  line-height: 1.6;
  color: inherit;
  outline: none;
  height: 100%;
  padding: 24px;
  border-radius: 16px;
  background-color: var(--note-bg);
  background-image: radial-gradient(var(--note-dot) 1.5px, transparent 1.5px);
  background-size: 40px 40px;
  background-attachment: local;
}

.no-note-dots #note-content,
html.no-note-dots #note-content {
  background-image: none;
}

.editor__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  gap: 24px;
}

.timer-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn--timer {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.icon-btn--timer .icon {
  width: 22px;
  height: 22px;
}

.font-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.font-controls .control--font {
  padding: 10px 14px;
  background: var(--surface-muted);
}

.font-controls .icon-btn {
  color: var(--text);
}

.font-controls .control--font input[type='range'] {
  flex: 1 1 auto;
  width: 220px;
  max-width: 100%;
}

#font-reset-btn {
  margin-left: 8px;
}

.settings__dialog {
  max-height: min(560px, 90vh);
  overflow-y: auto;
  gap: 24px;
}

.settings__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings__section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings__section h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.settings__option {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.settings__option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.settings__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.settings__section--danger {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.settings__section--danger h3,
.settings__section--danger .settings__hint {
  color: #b73c3c;
}

.settings__section--credits {
  border-top: 1px solid var(--border);
}

.settings__hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.danger__dialog {
  gap: 16px;
}

.danger__input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: inherit;
}

.danger__input:focus-visible {
  outline: 2px solid rgba(183, 60, 60, 0.4);
}

#timer-toggle[data-state="playing"] .icon--play {
  display: none;
}

#timer-toggle[data-state="playing"] .icon--pause {
  display: block;
}

#timer-toggle:not([data-state="playing"]) .icon--play {
  display: block;
}

#timer-toggle:not([data-state="playing"]) .icon--pause {
  display: none;
}

#timer-stop:disabled {
  opacity: 0.4;
  cursor: default;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  color: var(--text-muted);
}

.timer.is-active {
  color: var(--accent);
}

.timer.is-complete {
  color: #b25656;
  font-weight: 600;
}

body.theme-dark .timer.is-complete {
  color: #ff8f8f;
}

.timer:focus-visible {
  outline: 2px solid rgba(44, 93, 99, 0.4);
  outline-offset: 4px;
}

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease;
}

.btn:hover,
.btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: rgba(44, 93, 99, 0.12);
}

body.theme-dark .btn:hover,
body.theme-dark .btn:focus-visible {
  background: rgba(93, 163, 166, 0.18);
}

.btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(44, 93, 99, 0.18);
}

body.theme-dark .btn[aria-pressed="true"] {
  background: rgba(93, 163, 166, 0.24);
}

.btn--danger {
  border-color: rgba(183, 60, 60, 0.4);
  color: #b73c3c;
}

body.theme-dark .btn--danger {
  color: #ff8080;
  border-color: rgba(255, 128, 128, 0.4);
}

.btn--danger:hover,
.btn--danger:focus-visible {
  background: rgba(183, 60, 60, 0.12);
  border-color: rgba(183, 60, 60, 0.6);
}

input,
textarea,
button {
  font-family: inherit;
}

#search-input {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--surface);
  color: inherit;
  outline: none;
}

#search-input:focus-visible {
  border-color: var(--accent);
}

.control__field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--surface);
}

.control__suffix {
  font-size: 13px;
  color: var(--text-muted);
}

.control--timer input[type="number"] {
  width: 48px;
  border: none;
  background: transparent;
  font-size: 14px;
  text-align: right;
  color: inherit;
  outline: none;
  padding: 0;
  -moz-appearance: textfield;
}

.control--timer input[type="number"]:disabled {
  color: var(--text-muted);
}

.control--timer input[type="number"]::-webkit-outer-spin-button,
.control--timer input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.no-transitions *,
.no-transitions *::before,
.no-transitions *::after {
  transition: none !important;
}

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

  .app {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .app__overlay {
    display: block;
  }

  .app[data-sidebar="expanded"] .app__overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    max-width: 320px;
    width: min(90vw, 320px);
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
    padding: 32px 24px;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: 20;
  }

  .app[data-sidebar="expanded"] .sidebar {
    transform: translateX(0);
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .app[data-sidebar="collapsed"] {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .editor {
    padding: 24px;
    height: auto;
    min-height: 100vh;
  }

  .editor__meta-row.editor__meta-row--stacked {
    width: 100%;
    gap: 16px;
  }

  .editor__meta-row.editor__meta-row--stacked #note-title {
    flex: 1 1 auto;
  }

  .editor__footer {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
  }

  .font-controls {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: space-between;
  }

  .font-controls .control--font {
    flex: 1 1 auto;
    justify-content: space-between;
  }

  .font-controls .control--font input[type='range'] {
    width: 100%;
  }

  .timer-controls {
    justify-content: flex-start;
  }

  #font-reset-btn {
    margin-left: 16px;
  }

  #note-content {
    min-height: 55vh;
  }

  .editor__topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
  }

  .editor__actions {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .editor {
    padding: 20px 18px 28px;
    height: auto;
  }

  #note-title {
    font-size: 24px;
  }

  .editor__actions {
    gap: 12px;
  }
}
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 40;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 16, 15, 0.55);
  backdrop-filter: blur(4px);
}

.modal__dialog {
  position: relative;
  background: var(--surface);
  border-radius: 20px;
  padding: 28px;
  min-width: min(420px, calc(100vw - 48px));
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal__title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.modal__body {
  margin: 0;
  line-height: 1.5;
  color: var(--text-muted);
}

.modal__option {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-muted);
}

.modal__option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn--ghost {
  background: transparent;
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  background: rgba(44, 93, 99, 0.12);
}
