﻿@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@500;600;700&display=swap");

:root {
  --font-primary: "Inter", "Segoe UI", sans-serif;
  --font-secondary: "Manrope", "Segoe UI", sans-serif;

  --color-bg-app: #f3f3f3;
  --color-text-main: #16181d;
  --color-text-muted: #586173;
  --color-text-inverse: #ffffff;

  --color-surface-1: #ffffff;
  --color-surface-2: #f8f9fc;
  --color-surface-3: #f0f0f0;

  --color-border-soft: #dddddd;
  --color-border-mid: #d8deeb;

  --color-accent: #4f6ef7;
  --color-accent-strong: #3d5be8;

  --shadow-card: 0 8px 24px rgb(16 24 40 / 0.09);
  --shadow-hero: 0 14px 34px rgb(16 24 40 / 0.12);
}

body.dark-mode {
  --color-bg-app: #16181c;
  --color-text-main: #e7e9ed;
  --color-text-muted: #b8bec8;
  --color-text-inverse: #f5f6f8;

  --color-surface-1: #1f2227;
  --color-surface-2: #272b31;
  --color-surface-3: #2d3239;

  --color-border-soft: #343942;
  --color-border-mid: #404752;

  --color-accent: #8ca0c1;
  --color-accent-strong: #9ab0d4;

  --shadow-card: 0 10px 28px rgb(0 0 0 / 0.28);
  --shadow-hero: 0 14px 34px rgb(0 0 0 / 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg-app);
  color: var(--color-text-main);
  font-family: var(--font-primary);
}

.home-shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 16px auto 34px;
}

.hero {
  position: relative;
  width: 100%;
  height: clamp(300px, 52vw, 520px);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-hero);
  border: 1px solid var(--color-border-soft);
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px;
  background: linear-gradient(180deg, rgb(0 0 0 / 0.08) 0%, rgb(0 0 0 / 0.55) 100%);
}

.hero-kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: rgb(255 255 255 / 0.84);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 5px 0 0;
  color: var(--color-text-inverse);
  font-size: clamp(28px, 5vw, 44px);
  font-family: var(--font-secondary);
}

.section-wrap {
  margin-top: 28px;
}

.section-header {
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0;
  font-size: clamp(22px, 3.4vw, 30px);
  font-family: var(--font-secondary);
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.category-block {
  background: var(--color-surface-1);
  border: 1px solid var(--color-border-soft);
  border-radius: 14px;
  padding: 16px;
}

.category-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-family: var(--font-secondary);
}

.cards-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.card {
  text-decoration: none;
  color: inherit;
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  border: 1px solid var(--color-border-mid);
  border-radius: 12px;
  padding: 10px;
  background: var(--color-surface-2);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--color-accent-strong);
  box-shadow: var(--shadow-card);
}

.card-thumb {
  width: 100px;
  height: 140px;
  border-radius: 8px;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface-3);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.link-card .card-thumb {
  width: 140px;
  height: 140px;
}

.link-card {
  grid-template-columns: 140px 1fr;
}

.card-thumb canvas,
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-fallback {
  color: var(--color-text-muted);
  font-size: 12px;
  text-align: center;
  padding: 8px;
}

.card-title {
  margin: 1px 0 6px;
  font-size: 16px;
  font-family: var(--font-secondary);
}

.card-description {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-muted);
}

.card-meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.status {
  padding: 16px;
  border-radius: 10px;
  border: 1px dashed var(--color-border-mid);
  color: var(--color-text-muted);
  background: var(--color-surface-1);
}

.floating-actions {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 15;
  display: grid;
  gap: 10px;
}

.home-questions-wrap {
  position: relative;
}

.action-btn {
  cursor: pointer;
  border: 1px solid var(--color-border-mid);
  background: var(--color-surface-1);
  color: var(--color-text-main);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
}

.action-btn:hover {
  border-color: var(--color-accent-strong);
}

.action-btn.active {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.action-btn.small {
  width: 36px;
  height: 36px;
}

.icon {
  width: 18px;
  height: 18px;
  color: currentColor;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-questions-tray {
  position: absolute;
  left: calc(100% + 10px);
  bottom: 0;
  width: min(360px, calc(100vw - 86px));
  max-height: min(70vh, 560px);
  overflow: hidden;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--color-border-mid);
  background: var(--color-surface-1);
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.home-questions-tray.is-open,
.home-questions-wrap:hover .home-questions-tray,
.home-questions-wrap:focus-within .home-questions-tray {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.home-questions-title {
  padding: 2px 2px 8px;
  font-size: 12px;
  color: var(--color-text-muted);
  font-family: var(--font-secondary);
}

.home-questions-list {
  display: grid;
  gap: 8px;
  max-height: min(66vh, 510px);
  overflow-y: auto;
  padding-right: 2px;
}

.home-question-card {
  display: grid;
  grid-template-columns: 1fr 32px;
  gap: 8px;
  align-items: start;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--color-border-mid);
  background: var(--color-surface-2);
}

.home-question-open {
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.home-question-book {
  font-size: 12px;
  font-family: var(--font-secondary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-question-page {
  margin-top: 2px;
  font-size: 11px;
  color: var(--color-text-muted);
}

.home-question-text {
  margin-top: 4px;
  font-size: 11px;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-question-delete {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border-radius: 8px;
  padding: 0;
}

.home-question-delete .icon {
  width: 15px;
  height: 15px;
}

.home-questions-empty {
  border: 1px dashed var(--color-border-mid);
  border-radius: 10px;
  background: var(--color-surface-2);
  padding: 10px;
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(14 18 28 / 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 25;
  padding: 24px;
}

.settings-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.settings-island {
  width: min(460px, calc(100vw - 32px));
  background: var(--color-surface-1);
  border: 1px solid var(--color-border-mid);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-card);
}

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

.settings-island-header h2 {
  margin: 0;
  font-size: 22px;
  font-family: var(--font-secondary);
}

.settings-group {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-soft);
  border-radius: 10px;
  padding: 12px;
}

.settings-group h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-family: var(--font-secondary);
}

.settings-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 7px 0;
}

@media (max-width: 720px) {
  .home-shell {
    width: calc(100vw - 20px);
    margin-top: 10px;
  }

  .hero {
    height: clamp(250px, 70vw, 390px);
    border-radius: 14px;
  }

  .category-block {
    padding: 12px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .card {
    grid-template-columns: 86px 1fr;
    padding: 9px;
  }

  .card-thumb {
    width: 86px;
    height: 122px;
  }

  .link-card .card-thumb {
    width: 122px;
    height: 122px;
  }

  .link-card {
    grid-template-columns: 122px 1fr;
  }
}
