:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #252a34;
  --muted: #858b98;
  --border: #e8eaf0;
  --accent: #4169ad;
  --accent-light: #edf2fb;
  --danger: #c94b4b;
  --shadow: 0 5px 20px rgba(30, 45, 70, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* Шапка */

.app {
  max-width: 1600px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 42px 18px;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: var(--accent);
  color: white;
  font-size: 27px;
  font-weight: bold;
}

.brand-name {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-slogan {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 21px;
}

/* Информационная строка */

.info-strip {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-icon {
  color: var(--accent);
  font-size: 17px;
}

/* Поиск */

.search-section {
  display: flex;
  justify-content: center;
  margin: 22px 0 30px;
}

.search-box {
  width: min(100%, 620px);
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 7px 5px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.search-icon {
  color: var(--muted);
  font-size: 24px;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
}

.search-box button,
.primary-button {
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 10px 17px;
}

.search-box button:hover,
.primary-button:hover {
  background: #34578f;
}

/* Рабочая область */

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 28px;
  flex: 1;
}

.sidebar {
  padding: 18px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  align-self: start;
}

.sidebar-heading {
  margin: 0 0 16px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}

.groups-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.group-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.group-button:hover {
  background: #f5f6f9;
}

.group-button.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.group-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #aab4c5;
}

.group-button.active .group-dot {
  background: var(--accent);
}

.add-group-button {
  width: 100%;
  margin-top: 13px;
  padding: 11px 8px;
  border: 1px dashed #cbd0da;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.add-group-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Закладки */

.bookmarks-section {
  min-width: 0;
}

.bookmarks-header {
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 18px;
}

.bookmarks-header h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.bookmarks-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.bookmark-tile {
  position: relative;
  min-width: 0;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(30, 45, 70, 0.025);
  transition: transform 0.15s, box-shadow 0.15s;
}

.bookmark-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.bookmark-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 19px;
  font-weight: 600;
}

.bookmark-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.bookmark-title {
  max-width: 100%;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-edit {
  position: absolute;
  top: 5px;
  right: 7px;
  width: 25px;
  height: 25px;
  border: none;
  border-radius: 6px;
  background: #f0f2f6;
  color: #697386;
  opacity: 0;
}

.bookmark-tile:hover .bookmark-edit {
  opacity: 1;
}

.empty-message {
  padding: 50px 15px;
  color: var(--muted);
  text-align: center;
}

/* Подвал */

footer {
  padding-top: 25px;
  color: #a0a5af;
  font-size: 12px;
  text-align: center;
}

footer span {
  padding: 0 5px;
}

/* Окна */

.modal,
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(25, 32, 45, 0.42);
}

.modal-box,
.login-box {
  width: min(100%, 420px);
  padding: 25px;
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.modal-header h2,
.login-box h1 {
  margin: 0;
  font-size: 21px;
}

.close-button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 27px;
}

.modal-box label {
  display: block;
  margin: 14px 0 7px;
  color: var(--muted);
  font-size: 13px;
}

.modal-box input,
.modal-box select,
.login-box input {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: white;
  color: var(--text);
}

.modal-box input:focus,
.modal-box select:focus,
.login-box input:focus {
  border-color: var(--accent);
}

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

.danger-button {
  margin-right: auto;
  padding: 10px 14px;
  border: 1px solid #f0d1d1;
  border-radius: 8px;
  background: #fff5f5;
  color: var(--danger);
}

.error {
  min-height: 18px;
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
}

/* Вход */

.login-screen {
  background: var(--bg);
}

.login-box {
  text-align: center;
}

.login-box .brand-mark {
  margin: 0 auto 17px;
}

.login-box p {
  margin: 8px 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.login-box input {
  margin-bottom: 12px;
}

.login-box button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
}

/* Адаптация */

@media (max-width: 1100px) {
  .bookmarks-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app {
    padding: 18px 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .sidebar {
    padding: 13px;
  }

  .groups-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .group-button {
    width: auto;
  }

  .add-group-button {
    width: auto;
    margin-top: 8px;
  }

  .bookmarks-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
  }

  .bookmarks-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .info-strip {
    flex-wrap: wrap;
    gap: 10px 20px;
  }
}

@media (max-width: 400px) {
  .bookmarks-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-box button {
    padding: 10px 12px;
  }
}
/* Управление группами */

.group-row {
  display: flex;
  align-items: center;
  gap: 3px;
  border-radius: 8px;
}

.group-row .group-button {
  flex: 1;
  min-width: 0;
}

.group-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.group-row:hover .group-actions {
  opacity: 1;
}

.group-action {
  width: 27px;
  height: 29px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.group-action:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.group-action.delete:hover {
  background: #fff0f0;
  color: var(--danger);
}

@media (max-width: 760px) {
  .group-actions {
    opacity: 1;
  }
}
