@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,500&family=Manrope:wght@400;500;600;700&family=Literata:ital,wght@0,400;0,500;1,400;1,500&display=swap');

:root {
  --font-title: 'Cormorant Garamond', Georgia, serif;   /* «Хайку», заголовки разделов */
  --font-body: 'Manrope', system-ui, sans-serif;          /* интерфейс: кнопки, меню, подсказки, служебный текст */
  --font-haiku: 'Literata', Georgia, serif;                /* сам текст хайку */
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;
  --accent: #e8a5b8;
  --accent-soft: rgba(232, 165, 184, .22);
  --ok: #4a8a5c;
  --sidebar-w: 190px;
  --sidebar-w-collapsed: 64px;
  --glass-blur: blur(7px);
  --sidebar-blur: blur(7.35px); /* на 5% сильнее, чем базовый --glass-blur */
}

body[data-theme="light"] {
  --text: #2b2620;
  --text-muted: #6b6152;
  --border: rgba(60, 45, 25, .16);
  --card-shadow: 0 6px 20px rgba(60, 45, 25, .08);
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .82);
  --sidebar-glass: rgba(255, 255, 255, .50);
  --chip-bg: rgba(255, 255, 255, .60);
  --scrim: rgba(255, 255, 255, .14);
  --scrollbar-thumb: rgba(60, 45, 25, .28);
  --scrollbar-thumb-hover: rgba(60, 45, 25, .45);
}

body[data-theme="dark"] {
  --text: #eef1f6;
  --text-muted: #a7b2c4;
  --border: rgba(255, 255, 255, .14);
  --card-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  --glass: rgba(10, 16, 26, .55);
  --glass-strong: rgba(10, 16, 26, .78);
  --sidebar-glass: rgba(6, 11, 18, .48);
  --chip-bg: rgba(255, 255, 255, .09);
  --scrim: rgba(0, 0, 0, .22);
  --scrollbar-thumb: rgba(255, 255, 255, .22);
  --scrollbar-thumb-hover: rgba(255, 255, 255, .38);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body { color: var(--text); font-family: var(--font-body); position: relative; }
h1, h2, h3 { font-family: var(--font-title); margin: 0; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; color: var(--text); }
input { font-family: inherit; color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 14.5px; }

/* Красивые скроллы везде, где нужны */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ===== Фоновая иллюстрация (день/ночь) ===== */
.app-bg { position: fixed; inset: 0; z-index: -1; background-size: cover; background-position: center; }
body[data-theme="light"] .app-bg { background-image: url('../assets/day.webp'); }
body[data-theme="dark"] .app-bg { background-image: url('../assets/night.webp'); }
.app-bg::after { content: ''; position: absolute; inset: 0; background: var(--scrim); }

/* ===== Индикатор офлайн/синхронизации ===== */
.offline-banner {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--glass-strong); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); color: var(--text); font-size: 13.5px;
  padding: 7px 16px; border-radius: 999px; box-shadow: var(--card-shadow);
  display: flex; align-items: center; gap: 7px; max-width: calc(100vw - 32px); text-align: center;
  transition: opacity .25s ease;
}
.offline-banner::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: #d1544a; flex-shrink: 0;
}
.offline-banner.banner-online::before { background: var(--ok); }
.offline-banner.fading { opacity: 0; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; height: 100dvh; }

/* ===== Sidebar: градиент сверху вниз — внизу полностью прозрачный ===== */
.sidebar {
  background: linear-gradient(to bottom, var(--sidebar-glass) 0%, var(--sidebar-glass) 40%, transparent 100%);
  backdrop-filter: var(--sidebar-blur);
  -webkit-backdrop-filter: var(--sidebar-blur);
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 0%, black 55%, transparent 100%);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  transition: width .2s ease;
  width: var(--sidebar-w);
  overflow: visible;
}
.sidebar-top { display: flex; align-items: center; justify-content: flex-end; }
.collapse-btn { border: 1px solid var(--border); border-radius: 50%; width: 26px; height: 26px; background: var(--chip-bg); }
.collapse-btn svg { transition: transform .2s ease; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border: none; background: transparent; border-radius: var(--radius-sm);
  color: var(--text); font-size: 15px; font-weight: 700; text-align: left; white-space: nowrap; overflow: hidden;
  transition: background .15s ease, color .15s ease;
}
.nav-icon { display: flex; flex-shrink: 0; }
.nav-item:hover { background: var(--chip-bg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-divider { height: 1px; background: var(--border); margin: 6px 0; }

/* Свёрнутый сайдбар — только иконки */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .collapse-btn svg { transform: rotate(180deg); }
.app-shell:has(.sidebar.collapsed) { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ===== Content ===== */
.content { padding: 12px 22px 14px; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.desktop-topbar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex: 0 0 auto; }
.link-btn { display: flex; align-items: center; gap: 6px; background: none; border: none; color: var(--text-muted); font-size: 13px; }

/* ===== Музыкальный плеер (иконка ноты + всплывающие контролы слева от неё) ===== */
.topbar-controls { display: flex; align-items: center; gap: 10px; }
.player-controls {
  display: flex; align-items: center; gap: 8px;
  background: var(--chip-bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px 4px 6px; animation: player-in .18s ease;
}
.player-controls.hidden { display: none; }
@keyframes player-in { from { opacity: 0; transform: translateX(6px); } to { opacity: 1; transform: translateX(0); } }
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes page-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.content.page-enter { animation: page-in .6s cubic-bezier(.22,.68,.36,1) both; }
.play-pause-btn { background: var(--accent); color: #fff; border: none; }
.progress-range {
  -webkit-appearance: none; appearance: none; width: 90px; height: 3px; border-radius: 999px;
  background: var(--border); outline: none; cursor: pointer;
}
.progress-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--glass-strong);
}
.progress-range::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid var(--glass-strong); cursor: pointer;
}
.progress-range::-moz-range-track { background: var(--border); height: 3px; border-radius: 999px; }
.icon-btn { background: none; border: none; color: var(--text); padding: 5px; display: flex; align-items: center; justify-content: center; }
.icon-btn.round { width: 32px; height: 32px; border-radius: 50%; background: var(--chip-bg); border: 1px solid var(--border); }
.icon-btn.round:hover { border-color: var(--accent); }
.icon-btn.round.small { width: 24px; height: 24px; flex-shrink: 0; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view.view-enter { animation: view-in .3s ease both; }

.page-head { text-align: center; margin: 0 0 10px; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0; }
.page-head h1 { font-size: clamp(22px, 2.6vw, 32px); }
.brand-title { font-family: var(--font-title); font-size: clamp(100px, 4vw, 180px) !important; font-weight: 600; line-height: 0.7; }
.sakura-emblem {
  display: flex; justify-content: center; align-items: center; margin: -2px auto 0;
  background: none; border: none; padding: 4px; border-radius: 50%; width: 38px; height: 38px;
}
.sakura-emblem:hover { background: var(--chip-bg); }
.sakura-emblem:active { transform: scale(.93); }
.tagline { color: var(--text-muted); font-size: 15px; }

/* ===== Editor ===== */
.create-grid { display: grid; grid-template-columns: 1fr 260px; gap: 16px; flex: 1; min-height: 0; max-width: 780px; width: 100%; margin: 0 auto; align-self: center; }
.editor-card {
  background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--card-shadow);
  align-self: start;
}
.lines { display: flex; flex-direction: column; gap: 10px; }
.line-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--chip-bg); padding: 10px 14px; }
.line-num {
  width: 20px; height: 20px; border-radius: 50%; background: var(--chip-bg); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; border: 1px solid var(--border);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.line-num.ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.line-main { flex: 1; min-width: 0; position: relative; }
.line-input { width: 100%; border: none; background: none; color: var(--text); font-family: var(--font-haiku); font-size: 18px; outline: none; }
.line-input::placeholder { color: var(--text-muted); opacity: .6; }
.line-hyphen {
  font-family: var(--font-haiku); font-size: 13px; line-height: 1.4; color: var(--text-muted);
  letter-spacing: .2px; margin-top: 3px; min-height: 18px;
}
.syllable-dots { display: flex; gap: 4px; margin-top: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.dot.filled { background: var(--ok); }
.dot.over { background: #d1544a; }
.line-count { font-size: 12px; color: var(--text-muted); min-width: 32px; text-align: right; }
.line-check { width: 18px; display: flex; justify-content: center; }
.line-check svg { color: var(--border); }
.line-check.ok svg { color: var(--ok); }

.editor-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.btn { border-radius: 999px; border: 1px solid var(--border); padding: 8px 15px; font-size: 15px; display: flex; align-items: center; gap: 6px; background: var(--chip-bg); color: var(--text); white-space: nowrap; transition: background .15s ease, border-color .15s ease, transform .1s ease, filter .15s ease; }
.btn:active { transform: scale(.97); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-accent:hover { filter: brightness(1.05); }
.btn-sakura { background: var(--accent); border-color: var(--accent); color: #4a2430; font-weight: 600; }
.btn-sakura:hover { filter: brightness(1.05); }

/* ===== Автоподсказки слов ===== */
.suggest-box {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--glass-strong); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--card-shadow);
  padding: 6px; display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto;
}
.suggest-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: none; background: none; color: var(--text); font-size: 15.5px; font-family: var(--font-haiku);
  padding: 7px 9px; border-radius: var(--radius-sm); text-align: left; width: 100%;
}
.suggest-item:hover { background: var(--chip-bg); }
.suggest-word { font-family: var(--font-haiku); }
.mini-dots { display: flex; gap: 3px; flex-shrink: 0; }
.mini-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: .55; }

/* ===== Side cards ===== */
.side-cards { display: flex; flex-direction: column; gap: 10px; }
.info-card {
  background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 13px 15px; box-shadow: var(--card-shadow);
}
.info-card h3 { font-size: 20px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.structure-row { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid var(--border); font-size: 12.5px; }
.structure-row:first-of-type { border-top: none; }

/* ===== Карусель советов: две карточки, плавная ротация ===== */
.tips-carousel { display: flex; flex-direction: column; gap: 10px; }
.tip-card-mini {
  background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 13px 15px; box-shadow: var(--card-shadow);
  transition: opacity 1.4s ease, transform 1.4s ease;
}
.tip-card-mini.tip-fade { opacity: 0; transform: translateY(6px); }
.tip-card-mini .tip-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; color: var(--accent); }
.tip-card-mini .tip-text { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); font-family: var(--font-body); }

/* ===== Мои хайку — карточки шириной по содержимому строки ===== */
.saved-grid {
  display: flex; flex-wrap: wrap; gap: 10px;
  flex: 1; min-height: 0; overflow-y: auto; align-content: flex-start; padding: 2px;
}
.saved-card {
  background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 15px 84px 15px 15px;
  box-shadow: var(--card-shadow); position: relative;
  width: max-content; max-width: 100%;
  display: flex; flex-direction: column; gap: 9px;
  animation: card-in .35s ease both;
}
.saved-card .del-btn { background: none; border: none; color: var(--text-muted); }
.saved-card .del-btn:hover { color: #d1544a; }
.empty-note { text-align: center; color: var(--text-muted); margin-top: 24px; }
.infinite-sentinel { width: 100%; height: 1px; flex-basis: 100%; grid-column: 1 / -1; }

/* Кнопки-иконки в углу карточки: сохранить как изображение / удалить */
.card-actions { position: absolute; top: 11px; right: 11px; display: flex; gap: 6px; }
.card-img-btn {
  background: none; border: none; color: var(--text-muted); padding: 2px;
  display: flex; align-items: center; justify-content: center;
}
.card-img-btn:hover { color: var(--accent); }
.inspire-card, .pub-card { position: relative; }
.inspire-card > .card-img-btn, .pub-card > .card-img-btn { position: absolute; top: 11px; right: 11px; }

/* Общий стиль текста хайку — как в «Вдохновении» (карточки увеличены ~12% для читаемости) */
.lines-preview, .inspire-text {
  font-family: var(--font-haiku); font-style: italic; line-height: 1.5; font-size: 17px;
}
.lines-preview div { white-space: nowrap; }
.inspire-text div { white-space: normal; overflow-wrap: break-word; }

/* Строка метаданных под текстом хайку: дата (всегда справа), автор, публикация */
.card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-date { font-size: 14px; color: var(--text-muted); white-space: nowrap; margin-left: auto; }
.card-author { font-size: 15.5px; color: var(--text-muted); font-style: normal; }
.publish-toggle {
  border: 1px solid var(--border); background: var(--chip-bg); color: var(--text-muted);
  font-size: 14px; padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.publish-toggle.active { border-color: var(--ok); color: var(--ok); background: rgba(74,138,92,.12); }

.inspire-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 11px;
  flex: 1; min-height: 0; overflow-y: auto; align-content: start;
}
.inspire-card {
  background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 15px 42px 15px 15px;
  box-shadow: var(--card-shadow); display: flex; flex-direction: column; gap: 9px;
  animation: card-in .35s ease both;
}
.inspire-author { font-size: 15.5px; color: var(--text-muted); text-align: right; font-style: normal; }

/* ===== Присланные хайку / Хайку Kovat ===== */
.pub-grid {
  display: flex; flex-wrap: wrap; gap: 11px;
  flex: 1; min-height: 0; overflow-y: auto; align-content: flex-start; padding: 2px;
}
.pub-card {
  background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 15px 42px 15px 15px;
  box-shadow: var(--card-shadow); position: relative; width: max-content; max-width: 100%;
  display: flex; flex-direction: column; gap: 9px;
  animation: card-in .35s ease both;
}
.pub-card.pending { border-color: var(--accent); }
.status-badge {
  align-self: flex-start; font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 999px;
}
.pub-actions { display: flex; gap: 6px; }
.btn.small { padding: 5px 12px; font-size: 15px; }

/* ===== Mobile ===== */
.mobile-topbar { display: none; }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }
.checkbox-row input { width: 15px; height: 15px; }
.success-text { color: var(--ok); font-size: 14px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.modal {
  background: var(--glass-strong); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-lg); padding: 20px; width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 9px; border: 1px solid var(--border); box-shadow: var(--card-shadow);
}
.modal.modal-fancy {
  background: linear-gradient(160deg, var(--glass-strong), var(--glass));
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,.25);
  box-shadow: 0 20px 60px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.25);
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal input { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; background: var(--chip-bg); color: var(--text); outline: none; font-size: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.error-text { color: #d1544a; font-size: 14px; }

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .app-shell:has(.sidebar.collapsed) { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 210px !important; z-index: 20;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
    mask-image: linear-gradient(to bottom, black 0%, black 70%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black 70%, transparent 100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed .nav-label { display: flex; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 9px 10px; }
  .collapse-btn { display: none; } /* на мобильном сворачивание не нужно — есть гамбургер */

  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
    border-bottom: 1px solid var(--border); background: var(--sidebar-glass);
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); flex: 0 0 auto;
  }
  .content { padding: 10px 12px 12px; }
  .desktop-topbar { display: none; }
  .page-head { margin: 0 0 8px; }
  .page-head h1 { font-size: 22px; }
  .create-grid { grid-template-columns: 1fr; gap: 10px; }
  .side-cards { display: none; }
  .line-input { font-size: 17px; }
  .saved-grid { flex-direction: column; }
  .saved-card { width: 100%; }
  .saved-card .lines-preview div { white-space: normal; }
  .pub-grid { flex-direction: column; }
  .pub-card { width: 100%; }
  .pub-card .lines-preview div { white-space: normal; }
  .app-bg { background-position: right center; }
  .progress-range { width: 64px; }
  .icon-btn.round { width: 30px; height: 30px; }
  .topbar-controls { gap: 8px; }
}
