:root {
  color-scheme: light;
  --page: #f5f7fb;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #476de1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

header {
  background: var(--surface);
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 1.4rem; }
h2 { font-size: 1rem; margin-top: 0; }

#notes-workspace {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  min-height: calc(100vh - 74px);
}

aside {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px;
}

aside p {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--page);
}

section {
  min-width: 0;
  padding: 28px;
}

#notes-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
  align-items: start;
}

.sticky-note {
  min-height: 185px;
  padding: 18px;
  border-radius: 13px;
  box-shadow: 0 5px 14px #0f172a12;
  overflow-wrap: anywhere;
  color: #283044;
}

.sticky-note h3 {
  font-size: 1rem;
  margin: 0 0 12px;
}

.sticky-note[data-color="yellow"] { background: #fff0a8; }
.sticky-note[data-color="pink"] { background: #f9c8d9; }
.sticky-note[data-color="blue"] { background: #c9dfff; }
.sticky-note[data-color="green"] { background: #ccefd5; }
.sticky-note[data-color="purple"] { background: #e3d4ff; }
.sticky-note[data-color="white"] { background: #ffffff; }

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #121a2b;
    --surface: #1c273b;
    --text: #f1f5f9;
    --muted: #a5b4c8;
    --border: #36445c;
  }
}

@media (max-width: 720px) {
  #notes-workspace { grid-template-columns: 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--border); }
  section { padding: 18px; }
}

/* Grid and Board workspace controls */
.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 22px;
}

.notes-toolbar h2 {
  margin: 0;
  font-size: 1.25rem;
}

.view-controls {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.view-controls button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 9px 15px;
  border-radius: 9px;
  cursor: pointer;
  font: inherit;
  font-size: .9rem;
}

.view-controls button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.view-controls button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Grid uses the existing responsive card layout. */
#notes-container.grid-layout {
  display: grid;
}

/* Board uses a separate positioning canvas. */
#notes-container.board-layout {
  display: block;
  position: relative;
  min-height: 650px;
  overflow: auto;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background-color: var(--surface);
  background-image: radial-gradient(
    circle, var(--border) 1px, transparent 1px
  );
  background-size: 22px 22px;
}

/* Cards will receive saved coordinates from JavaScript. */
.board-layout .sticky-note {
  position: absolute;
  width: 230px;
  min-height: 185px;
  touch-action: none;
}

/* SkyCloud Notes — Sticky Note Editor */
.notes-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

#new-note, #save-note {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#note-editor {
  width: min(92vw, 540px);
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 70px #0004;
}

#note-editor::backdrop {
  background: rgba(10, 20, 40, .65);
}

#note-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#note-form label {
  font-size: .9rem;
  font-weight: 600;
}

#note-form input,
#note-form textarea,
#note-form select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--page);
  color: var(--text);
  font: inherit;
}

#note-form textarea {
  resize: vertical;
  min-height: 160px;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

#cancel-note {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 18px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

#note-error {
  color: #dc3545;
  font-size: .9rem;
  min-height: 1em;
}

@media (max-width: 720px) {
  #note-editor { padding: 18px; }
  .notes-actions { width: 100%; }
}


/* SkyCloud Notes workspace and notebook navigation */
.nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.nav-heading h2 { margin: 0; }
.notebooks-heading { margin-top: 28px; }
.nav-heading button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 8px;
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
}
button:disabled { opacity: .45; cursor: not-allowed; }
.navigation-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  margin: 5px 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.navigation-item:hover { background: var(--page); }
.navigation-item[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
#workspace-list, #notebook-list { overflow-wrap: anywhere; }
#navigation-message { color: var(--muted); font-size: .85rem; }
.navigation-dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  padding: 26px;
}
.navigation-dialog::backdrop { background: #0f172a99; }
.navigation-dialog form { display: grid; gap: 14px; }
.navigation-dialog input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
}
.navigation-dialog .editor-actions { justify-content: flex-end; }
.navigation-dialog [type="submit"] {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 9px;
  padding: 10px 16px;
  cursor: pointer;
}

/* SKYNOTES-APPEARANCE-V1 */
:root[data-notes-theme="light"] {
  color-scheme: light;
  --page: #f5f7fb;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
}
:root[data-notes-theme="dark"] {
  color-scheme: dark;
  --page: #121a2b;
  --surface: #1c273b;
  --text: #f1f5f9;
  --muted: #a5b4c8;
  --border: #36445c;
}
.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.appearance-menu {
  position: relative;
}
.appearance-menu summary {
  cursor: pointer;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  list-style: none;
}
.appearance-menu summary::-webkit-details-marker {
  display: none;
}
.appearance-menu[open] fieldset {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 100;
  width: 185px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 10px 30px #0002;
}
.appearance-menu legend {
  color: var(--muted);
  font-size: .85rem;
}
.appearance-menu label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 5px;
  cursor: pointer;
}
.appearance-menu input {
  accent-color: var(--accent);
}

/* SKYNOTES-GROUPS-V2 */
#group-list { overflow-wrap: anywhere; }
#group-list .navigation-item { padding-left: 14px; }
#group-list .navigation-item[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
