/* Книга миров — уютная библиотека: бумага, чернила, дерево, свеча */

:root {
  --paper: #f6efe1;
  --paper-card: #fbf6ea;
  --ink: #3b2e22;
  --ink-soft: #6e5b47;
  --leather: #4a3423;
  --leather-deep: #3a2818;
  --gold: #c09553;
  --gold-soft: #d9bd8c;
  --line: #e2d5bc;
  --shadow: rgba(59, 46, 34, .16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(192,149,83,.10), transparent 60%),
    var(--paper);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: 96px;
}

/* --- обложка --- */
.cover {
  background:
    radial-gradient(ellipse at 50% 130%, rgba(192,149,83,.28), transparent 65%),
    linear-gradient(175deg, var(--leather), var(--leather-deep));
  color: var(--gold-soft);
  text-align: center;
  padding: 26px 16px 20px;
  border-bottom: 3px double var(--gold);
  box-shadow: 0 4px 18px var(--shadow);
}
.cover.hall {
  background-size: cover;
  background-position: center 68%;
  padding: 44px 16px 30px;
  text-shadow: 0 1px 8px rgba(20, 12, 5, .85);
  transition: background-image .6s ease;
}
.cover-ornament { font-size: 18px; color: var(--gold); margin-bottom: 4px; }
.cover h1 {
  font-size: 26px;
  font-weight: normal;
  letter-spacing: .12em;
}
.cover-sub {
  margin-top: 6px;
  font-style: italic;
  font-size: 13px;
  color: rgba(217,189,140,.75);
}

/* --- полки --- */
.shelves {
  display: flex;
  gap: 8px;
  padding: 14px 14px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.shelves::-webkit-scrollbar { display: none; }
.shelf {
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all .15s ease;
}
.shelf.active {
  background: var(--leather);
  color: var(--gold-soft);
  border-color: var(--leather);
}

/* --- поиск --- */
.search-row { padding: 10px 14px 2px; }
#search {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  outline: none;
}
#search::placeholder { color: #a8967d; font-style: italic; }
#search:focus { border-color: var(--gold); }

/* --- карточки --- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 14px;
}
.card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: 0 1px 4px var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 5px 14px var(--shadow); }
.card .thumb {
  width: calc(100% + 32px);
  margin: -14px -16px 10px;
  height: 150px;
  object-fit: cover;
  border-radius: 7px 7px 0 0;
  border-bottom: 1px solid var(--line);
  display: block;
}
.card .kind {
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.card h3 { font-size: 17px; font-weight: normal; margin-bottom: 6px; }
.card p {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .tags { margin-top: 8px; font-size: 12px; font-style: italic; color: #a8967d; }

/* --- пусто --- */
.empty { text-align: center; padding: 56px 24px; color: var(--ink-soft); }
.empty-orn { font-size: 26px; color: var(--gold); margin-bottom: 10px; }
.empty p { font-style: italic; font-size: 15px; }

/* --- перо (добавить) --- */
.fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: linear-gradient(160deg, var(--leather), var(--leather-deep));
  color: var(--gold-soft);
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--shadow);
  transition: transform .12s ease;
}
.fab:active { transform: scale(.94); }

/* --- модалка --- */
.veil[hidden] { display: none; }
.veil {
  position: fixed;
  inset: 0;
  background: rgba(42, 30, 18, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
@media (min-width: 640px) { .veil { align-items: center; } }
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--paper);
  border-top: 3px double var(--gold);
  border-radius: 16px 16px 0 0;
  padding: 20px 18px 24px;
}
@media (min-width: 640px) { .sheet { border-radius: 14px; border: 1px solid var(--gold); } }

.sheet .kind-line {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}
.sheet h2 { font-weight: normal; font-size: 21px; margin-bottom: 10px; }
.sheet .content { font-size: 15px; line-height: 1.65; white-space: pre-wrap; color: var(--ink); }
.sheet .view-img, .sheet .form-img {
  max-width: 100%;
  max-height: 320px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 4px 0 12px;
  box-shadow: 0 2px 8px var(--shadow);
  display: block;
}
.sheet .form-img { max-height: 180px; margin-top: 8px; }
.sheet .meta { margin-top: 14px; font-size: 12px; font-style: italic; color: #a8967d; }

.sheet label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 12px 0 4px;
  font-style: italic;
}
.sheet input[type="text"], .sheet textarea, .sheet select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
.sheet input:focus, .sheet textarea:focus, .sheet select:focus { border-color: var(--gold); }
.sheet textarea { min-height: 140px; resize: vertical; line-height: 1.55; }

.sheet .row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--paper-card);
  color: var(--ink);
}
.btn.primary {
  background: linear-gradient(160deg, var(--leather), var(--leather-deep));
  color: var(--gold-soft);
  border-color: var(--leather);
}
.btn.danger { color: #93402c; border-color: #d8b8a8; }
.btn.ghost { background: transparent; border: none; color: var(--ink-soft); }
.btn.danger.ghost { color: #93402c; }

/* --- писательский кабинет --- */
.study[hidden] { display: none; }
.study {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(192,149,83,.12), transparent 55%),
    var(--paper);
}
body.in-study { overflow: hidden; }
.study-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 246, 234, .75);
}
.study-status { font-size: 13px; font-style: italic; color: #a8967d; flex: 1; text-align: center; }
.study-page {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 20px 14px;
}
#storyTitle {
  font-family: inherit;
  font-size: 24px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 6px 2px 10px;
  outline: none;
  text-align: center;
}
#storyTitle::placeholder, #storyBody::placeholder { color: #b5a48b; font-style: italic; }
#storyBody {
  flex: 1;
  font-family: inherit;
  font-size: 17px;
  line-height: 1.8;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 18px 2px;
  min-height: 55vh;
}
.study-words {
  font-size: 12.5px;
  font-style: italic;
  color: #a8967d;
  text-align: right;
  padding: 6px 2px 10px;
}
.story-card { border-left-color: #8a5a33; }

/* --- печати --- */
.seals-intro {
  grid-column: 1 / -1;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
  padding: 4px 0 6px;
}
.seal-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.seal {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 12px 14px;
  text-align: center;
  box-shadow: 0 1px 4px var(--shadow);
}
.seal-medal {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: radial-gradient(circle at 35% 30%, #f4e6c8, #dfc491);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: inset 0 0 12px rgba(138, 90, 51, .25), 0 2px 6px var(--shadow);
}
.seal-medal img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.seal-medal img + span { visibility: hidden; }
.seal-name { font-size: 14.5px; margin-bottom: 5px; }
.seal-line { font-size: 12.5px; font-style: italic; color: var(--ink-soft); line-height: 1.45; }
.seal-date { font-size: 11.5px; color: #a8967d; margin-top: 7px; font-style: italic; }
.seal.locked { opacity: .62; }
.seal.locked .seal-medal {
  border-style: dashed;
  border-color: #c9b08d;
  background: var(--paper);
  color: #b5a48b;
  box-shadow: none;
  font-size: 26px;
}
