* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; margin: 0; background: #f5f5f7; color: #222; }
header { display: flex; justify-content: space-between; padding: 1rem 2rem; background: #fff; border-bottom: 1px solid #ddd; }
main { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; padding: 2rem; max-width: 1200px; margin: auto; }
.card { max-width: 360px; margin: 4rem auto; padding: 2rem; background: #fff; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
input, textarea, button { font: inherit; padding: .6rem .8rem; border-radius: 8px; border: 1px solid #ccc; width: 100%; margin: .3rem 0; }
button { background: #007aff; color: #fff; border: none; cursor: pointer; }
button:hover { background: #0062cc; }
.error { color: #c00; }
ul { list-style: none; padding: 0; }
li { padding: .4rem 0; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; }
li button { width: auto; padding: .2rem .5rem; background: #e33; }
#editor { margin-top: 1rem; }

/* ---------- Заметки: переключатель вид + цвета ---------- */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .8rem;
}
.section-header h2 { margin: 0; }

.view-toggle {
  display: inline-flex;
  border: 1px solid #ccc;
  border-radius: 8px;
  overflow: hidden;
}
.view-toggle button {
  background: #fff;
  color: #555;
  border: none;
  border-radius: 0;
  padding: .4rem .7rem;
  margin: 0;
  width: auto;
  cursor: pointer;
  font-size: 1rem;
  transition: background .15s, color .15s;
}
.view-toggle button:hover { background: #f0f0f0; }
.view-toggle button.active {
  background: #007aff;
  color: #fff;
}

/* Контейнер заметок */
#notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Режим СПИСОК */
#notes-list.view-list li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .6rem;
  border-bottom: 1px solid #eee;
  border-radius: 6px;
  transition: background .15s;
}
#notes-list.view-list li:hover { background: #f7f7f9; }
#notes-list.view-list .note-link {
  flex: 1;
  color: #007aff;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#notes-list.view-list .note-link:hover { text-decoration: underline; }

/* Режим ПЛИТКИ */
#notes-list.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .8rem;
}
#notes-list.view-grid li {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: .8rem;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e5e5e8;
  min-height: 100px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: transform .12s, box-shadow .12s;
}
#notes-list.view-grid li:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,.08);
}
#notes-list.view-grid .note-link {
  color: #333;
  text-decoration: none;
  font-weight: 500;
  word-break: break-word;
  flex: 1;
}
#notes-list.view-grid .note-link:hover { color: #007aff; }

/* Кружок выбора цвета */
.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,.15);
  cursor: pointer;
  flex-shrink: 0;
  background: #f0f0f0;
  transition: transform .12s, border-color .12s;
}
.color-dot:hover { transform: scale(1.2); border-color: #007aff; }

/* В плитке кружок в правом верхнем углу */
#notes-list.view-grid .color-dot {
  position: absolute;
  top: .5rem;
  right: .5rem;
}

/* Палитра цветов заметки */
.note-color-yellow  { background: #fff8c5; border-color: #f0d000; }
.note-color-green   { background: #d9f7d9; border-color: #52c452; }
.note-color-blue    { background: #d9ecff; border-color: #4a90e2; }
.note-color-pink    { background: #ffd9e8; border-color: #e26ba4; }
.note-color-purple  { background: #e8d9ff; border-color: #9b6ee2; }
.note-color-gray    { background: #ececec; border-color: #b0b0b0; }
/* Цвет плитки целиком (перебивает #notes-list.view-grid li) */
#notes-list.view-grid li.note-color-yellow {
  background: #fff8c5;
  border-color: #f0d000;
}
#notes-list.view-grid li.note-color-green {
  background: #d9f7d9;
  border-color: #52c452;
}
#notes-list.view-grid li.note-color-blue {
  background: #d9ecff;
  border-color: #4a90e2;
}
#notes-list.view-grid li.note-color-pink {
  background: #ffd9e8;
  border-color: #e26ba4;
}
#notes-list.view-grid li.note-color-purple {
  background: #e8d9ff;
  border-color: #9b6ee2;
}
#notes-list.view-grid li.note-color-gray {
  background: #ececec;
  border-color: #b0b0b0;
}
/* Меню выбора цвета (popup) */
.color-menu {
  position: absolute;
  z-index: 100;
  display: grid;
  grid-template-columns: repeat(3, 26px);
  gap: 6px;
  padding: 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.color-menu .color-option {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,.15);
  cursor: pointer;
  transition: transform .1s;
}
.color-menu .color-option:hover { transform: scale(1.15); }
.color-menu .color-option.selected {
  outline: 2px solid #007aff;
  outline-offset: 1px;
}
/* Дата изменения заметки */
.note-date {
  font-size: .75rem;
  color: #888;
  white-space: nowrap;
  flex-shrink: 0;
}

/* В списке — справа от названия */
#notes-list.view-list .note-date {
  margin-left: .5rem;
}

/* В плитке — внизу */
#notes-list.view-grid .note-date {
  position: absolute;
  bottom: .5rem;
  left: .6rem;
  font-size: .7rem;
}

/* ---------- Файлы: папки ---------- */
.breadcrumb {
  padding: .5rem .6rem;
  background: #f7f7f9;
  border-radius: 8px;
  margin-bottom: .8rem;
  font-size: .9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .1rem;
}
.breadcrumb a {
  color: #007aff;
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: #aaa; margin: 0 .2rem; }

.files-actions {
  display: flex;
  gap: .5rem;
  margin-bottom: .8rem;
  align-items: center;
  flex-wrap: wrap;
}
.files-actions input[type=file] {
  flex: 1;
  min-width: 200px;
  padding: .3rem;
}
.files-actions button {
  width: auto;
  padding: .5rem 1rem;
}

#files-list li {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  border-bottom: 1px solid #eee;
}
#files-list li:hover { background: #f7f7f9; }
#files-list li.empty {
  color: #999;
  font-style: italic;
  justify-content: center;
}

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #007aff;
  text-decoration: none;
}
.file-name:hover { text-decoration: underline; }
.file-name.is-folder {
  color: #d68a00;
  font-weight: 500;
}

.file-size {
  font-size: .8rem;
  color: #888;
  flex-shrink: 0;
}

.file-delete {
  width: 28px;
  height: 28px;
  padding: 0;
  background: #e33;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}
.file-delete:hover { background: #c00; }