/* EveryIdea app: layout, login, заметки, доски, календарь, настройки, адаптив. */

/* ============ Login gate ============ */
.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s4);
  padding-top: calc(var(--s4) + env(safe-area-inset-top));
  padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom));
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: var(--s8);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  animation: card-in 180ms ease;
}
.login-logo {
  display: grid;
  place-items: center;
  width: 64px; height: 64px;
  margin: 0 auto;
  border-radius: 20px;
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent);
}
.logo-star { width: 32px; height: 32px; }
.login-title {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-sub { text-align: center; font-size: 14px; color: var(--hint); }
.token-input {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-align: center;
  min-height: 48px;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-control);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
}
.token-input:focus { border-color: var(--accent); background: var(--surface); outline: none; }
.token-show-row {
  display: flex;
  gap: var(--s2);
  align-items: center;
}
.token-show {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 14px;
  padding: var(--s3);
  border-radius: var(--r-control);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: all;
}
.login-error {
  min-height: 18px;
  font-size: 13px;
  color: var(--destructive);
  text-align: center;
}
.login-error:empty { margin: calc(-1 * var(--s2)) 0; }

.shake { animation: shake 400ms ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

/* ============ Shell ============ */
.shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 1fr auto;
}
.sidebar {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s5) var(--s3);
  padding-top: calc(var(--s5) + env(safe-area-inset-top));
  border-right: 1px solid var(--separator);
  background: var(--surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s2);
}
.sidebar-logo .logo-star { width: 24px; height: 24px; color: var(--accent); }
.sidebar-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  min-height: 40px;
  border-radius: var(--r-control);
  color: var(--hint);
  font-weight: 500;
  font-size: 14px;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav-btn:hover { color: var(--text); background: var(--fill); }
.nav-btn.active { color: var(--accent); background: var(--accent-soft); }

.content {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
}
.bottom-nav { display: none; }

.view { display: none; flex: 1; min-width: 0; min-height: 0; }
.view.active-view { display: flex; }

.pane {
  background: var(--surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}
.pane-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--separator);
}
.pane-title { font-size: 17px; font-weight: 700; flex: 1; }

/* ============ Заметки ============ */
.notes-view { display: none; }
.notes-view.active-view { display: flex; }
.notes-list-pane {
  width: 320px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--separator);
}
.search-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}
.search-wrap .icon {
  position: absolute;
  left: var(--s3);
  width: 16px; height: 16px;
  color: var(--hint);
  pointer-events: none;
}
.search-input { width: 100%; padding-left: 36px; }

.note-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.note-card {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s3);
  border-radius: var(--r-control);
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow);
  animation: card-in 150ms ease both;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.note-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.note-card.active { border-color: var(--accent); }
.note-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s2);
}
.note-card-title {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-card-snippet {
  font-size: 12.5px;
  color: var(--hint);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.note-card-meta { font-size: 11px; color: var(--hint); }

.note-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}
.editor-toolbar { flex-wrap: wrap; }
.note-title {
  flex: 1;
  min-width: 140px;
  font-weight: 600;
  font-size: 16px;
}
.note-date { width: 150px; }
.editor-stack { flex: 1; min-height: 0; display: flex; }
.note-body {
  flex: 1;
  border: none;
  resize: none;
  padding: var(--s5) var(--s6);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.65;
  background: transparent;
  color: var(--text);
}
.note-body:focus { outline: none; }

.md-preview {
  flex: 1;
  overflow-y: auto;
  padding: var(--s5) var(--s6);
  font-size: 15px;
  line-height: 1.65;
  word-wrap: break-word;
}
.md-preview h1, .md-preview h2, .md-preview h3 { letter-spacing: -0.01em; margin: var(--s5) 0 var(--s2); }
.md-preview h1:first-child, .md-preview h2:first-child, .md-preview p:first-child { margin-top: 0; }
.md-preview p { margin: var(--s2) 0; }
.md-preview code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--fill);
  padding: 1px 5px;
  border-radius: 6px;
}
.md-preview pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: var(--s3) var(--s4);
  overflow-x: auto;
}
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote {
  margin: var(--s3) 0;
  padding: var(--s1) var(--s4);
  border-left: 3px solid var(--accent);
  color: var(--hint);
}
.md-preview ul, .md-preview ol { padding-left: var(--s6); margin: var(--s2) 0; }
.md-preview li { margin: 2px 0; }
.md-preview li:has(> input[type='checkbox']) { list-style: none; margin-left: calc(-1 * var(--s5)); }
.md-preview input[type='checkbox'] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  vertical-align: -2px;
  margin-right: var(--s2);
  cursor: pointer;
}
.md-preview a { color: var(--accent); }
.md-preview img { max-width: 100%; border-radius: var(--r-control); }
.md-preview table { border-collapse: collapse; margin: var(--s3) 0; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: var(--s1) var(--s3); font-size: 14px; }
.md-preview hr { border: none; border-top: 1px solid var(--separator); margin: var(--s4) 0; }

.editor-placeholder {
  position: absolute;
  inset: 57px 0 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  color: var(--hint);
  background: var(--bg-secondary);
}
.no-doc .editor-placeholder { display: flex; }
.no-doc .editor-toolbar, .no-doc .editor-stack { visibility: hidden; }

/* ============ Доски ============ */
.boards-view { display: none; }
.boards-view.active-view { display: flex; }
.boards-list-pane {
  width: 320px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--separator);
}
.board-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.board-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg-secondary);
}
.board-name { flex: 1; min-width: 120px; font-weight: 600; }

.board-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--separator);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.board-toolbar::-webkit-scrollbar { display: none; }
.board-tools { display: flex; gap: 2px; flex: none; }
.tool-btn {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  color: var(--hint);
  font-size: 16px;
  transition: background-color 120ms ease, color 120ms ease;
  flex: none;
}
.tool-btn .icon { width: 18px; height: 18px; }
.tool-btn:hover { color: var(--text); background: var(--fill); }
.tool-btn.active { color: var(--accent); background: var(--accent-soft); }
.toolbar-sep { width: 1px; height: 24px; background: var(--separator); flex: none; }

.color-row { display: flex; gap: var(--s1); flex: none; }
.color-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: transform 120ms ease;
  flex: none;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.active { border-color: var(--text); }

.width-select { min-height: 36px; padding: var(--s1) var(--s2); font-size: 13px; flex: none; }
.zoom-label { font-size: 12px; color: var(--hint); min-width: 42px; text-align: center; flex: none; font-variant-numeric: tabular-nums; }

.board-canvas-host {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
}
.board-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board-canvas-host[data-tool='select'] .board-canvas { cursor: default; }
.board-canvas-host[data-tool='eraser'] .board-canvas { cursor: cell; }
.board-canvas-host:not([data-tool='select']):not([data-tool='eraser']) .board-canvas { cursor: crosshair; }
.board-canvas-host.board-space .board-canvas { cursor: grab; }

.board-text-editor {
  position: absolute;
  z-index: 5;
  font-family: var(--font-ui);
  font-size: 15px;
  padding: var(--s2);
  border: 1.5px dashed var(--accent);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  resize: none;
  box-shadow: var(--shadow-lift);
}

/* ============ Календарь ============ */
.calendar-view { display: none; }
.calendar-view.active-view { display: flex; }
.calendar-layout {
  flex: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
}
.calendar-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--s4);
  gap: var(--s4);
  background: transparent;
  overflow-y: auto;
}
.cal-header {
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.cal-month-label { font-size: 18px; font-weight: 700; flex: 1; text-align: center; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--s1);
}
.cal-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  padding: var(--s2) 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-cell {
  min-height: 76px;
  border-radius: var(--r-control);
  border: 1px solid transparent;
  background: var(--surface);
  padding: var(--s2);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--s1);
  text-align: left;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  overflow: hidden;
}
.cal-day:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--border); }
.cal-blank { background: transparent; pointer-events: none; }
.cal-day-num { font-size: 13px; font-weight: 600; color: var(--text); align-self: flex-start; }
.cal-day.today .cal-day-num {
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 50%;
  width: 22px; height: 22px;
  display: grid;
  place-items: center;
}
.cal-day.selected { border-color: var(--accent); }
.cal-chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-chips .chip { font-size: 10px; padding: 0 6px; }

.day-panel {
  width: 320px;
  flex: none;
  border-left: 1px solid var(--separator);
  background: var(--surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  padding: var(--s4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.day-panel-head { display: flex; flex-direction: column; gap: var(--s3); }
.day-panel-title { font-size: 17px; font-weight: 700; }
.day-doc-list { display: flex; flex-direction: column; gap: var(--s2); }
.day-doc {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  border-radius: var(--r-control);
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: transform 150ms ease, box-shadow 150ms ease;
  animation: card-in 150ms ease both;
}
.day-doc:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.day-doc .icon { color: var(--accent); width: 18px; height: 18px; }
.day-doc-title { flex: 1; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ Настройки ============ */
.settings-view { display: none; }
.settings-view.active-view { display: flex; }
.settings-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.settings-section { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.settings-title { font-size: 15px; font-weight: 700; }
.settings-hint { font-size: 13px; color: var(--hint); }
.settings-foot { text-align: center; font-size: 12px; color: var(--hint); padding-bottom: var(--s4); }

.theme-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
.theme-card {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  align-items: center;
  padding: var(--s3);
  border-radius: var(--r-control);
  border: 2px solid var(--border);
  background: var(--surface);
  transition: border-color 150ms ease, transform 150ms ease;
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card.active { border-color: var(--accent); }
.theme-preview {
  width: 100%;
  height: 56px;
  border-radius: var(--r-sm);
  border: 1px solid var(--separator);
}
.theme-card-paper .theme-preview { background: linear-gradient(135deg, #fafaf7 60%, #4f46e5 60%); }
.theme-card-onyx .theme-preview { background: linear-gradient(135deg, #0a0a0b 60%, #6366f1 60%); }
.theme-card-aurora .theme-preview { background: linear-gradient(135deg, #1e1b4b, #312e81 55%, #22d3ee); }
.theme-name { font-size: 13px; font-weight: 600; }

/* ============ Адаптив ============ */

/* Планшет */
@media (max-width: 1024px) {
  .shell { grid-template-columns: 72px 1fr; }
  .sidebar { padding: var(--s4) var(--s2); }
  .sidebar-name { display: none; }
  .sidebar-logo { justify-content: center; padding: 0; }
  .nav-btn { justify-content: center; padding: var(--s2); }
  .nav-label { display: none; }
  .notes-list-pane, .boards-list-pane { width: 280px; }
  .day-panel { width: 280px; }
}

/* Телефон */
@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { display: none; }
  .content { grid-column: 1; grid-row: 1; }
  .bottom-nav {
    display: flex;
    grid-row: 2;
    border-top: 1px solid var(--separator);
    background: var(--surface);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    padding: var(--s1) var(--s2);
    padding-bottom: calc(var(--s1) + env(safe-area-inset-bottom));
  }
  .bottom-nav .nav-btn {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-height: 52px;
    font-size: 11px;
  }
  .bottom-nav .nav-label { display: block; }

  /* список/редактор — отдельные экраны */
  .notes-list-pane, .boards-list-pane { width: 100%; border-right: none; }
  .note-editor-pane, .board-editor-pane { display: none; }
  .editor-open .notes-list-pane, .editor-open .boards-list-pane { display: none; }
  .editor-open .note-editor-pane, .editor-open .board-editor-pane { display: flex; position: absolute; inset: 0; z-index: 10; }
  .note-editor-pane, .board-editor-pane { background: var(--surface); }
  .no-doc .editor-toolbar, .no-doc .editor-stack { visibility: visible; }
  .no-doc .editor-placeholder { display: none; }
  .editor-open.no-doc .editor-toolbar, .editor-open.no-doc .editor-stack { visibility: hidden; }
  .editor-open.no-doc .editor-placeholder { display: flex; }

  .back-btn { display: grid !important; }
  .calendar-layout { flex-direction: column; overflow-y: auto; }
  .calendar-main { overflow: visible; }
  .day-panel { width: 100%; border-left: none; border-top: 1px solid var(--separator); }
  .cal-cell { min-height: 52px; }
  .cal-chips .chip { font-size: 9px; }
  .settings-scroll { padding: var(--s4); }
  #toasts { align-items: stretch; }
  .toast { max-width: none; }
}

/* десктоп: назад-кнопка скрыта (список всегда виден) */
@media (min-width: 641px) {
  .back-btn { display: none !important; }
}

/* Очень узкий экран: компактный тулбар редактора */
@media (max-width: 400px) {
  .note-date { width: 128px; }
  .login-card { padding: var(--s5); }
  .token-show { font-size: 13px; letter-spacing: 0.04em; padding: var(--s3) var(--s2); }
}
