:root {
  color-scheme: light;
  --paper: #f7f4ef;
  --ink: #202226;
  --muted: #6f716f;
  --line: #d8d1c5;
  --panel: #fffdfa;
  --forest: #0f5f4c;
  --forest-dark: #0b493c;
  --brick: #a94332;
  --gold: #c79b31;
  --shadow: 0 18px 50px rgba(32, 34, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(15, 95, 76, 0.07) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(15, 95, 76, 0.06) 0 1px, transparent 1px 100%),
    var(--paper);
  background-size: 44px 44px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body.studio-page {
  background:
    radial-gradient(circle at top left, rgba(35, 82, 71, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(199, 155, 49, 0.14), transparent 26%),
    #111214;
  color: #f4f2ed;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-shell {
  width: min(100%, 430px);
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(26px, 7vw, 42px);
}

.login-mark {
  display: grid;
  grid-template-columns: repeat(3, 30px);
  gap: 8px;
  margin-bottom: 26px;
}

.login-mark span {
  display: block;
  width: 30px;
  height: 42px;
  border-radius: 3px;
}

.login-mark span:nth-child(1) {
  background: var(--forest);
}

.login-mark span:nth-child(2) {
  background: var(--brick);
}

.login-mark span:nth-child(3) {
  background: var(--gold);
}

h1,
h2,
p {
  margin-top: 0;
}

.login-panel h1,
.library-header h1 {
  margin-bottom: 24px;
  font-size: clamp(2rem, 7vw, 3.8rem);
  line-height: 0.96;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
}

.login-form input:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(15, 95, 76, 0.15);
  outline: none;
}

.login-form button,
.download-link,
.ghost-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.login-form button,
.download-link {
  background: var(--forest);
  color: #fff;
  padding: 0 18px;
}

.login-form button:hover,
.download-link:hover {
  background: var(--forest-dark);
}

.form-error {
  margin: 0;
  color: #8b281c;
  font-weight: 700;
}

.library-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(26px, 5vw, 58px) 0;
}

.library-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: clamp(22px, 5vw, 42px);
}

.library-header h1 {
  margin: 0;
}

.library-count {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--brick);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.85);
  color: var(--ink);
  padding: 0 15px;
}

.ghost-button:hover {
  border-color: var(--forest);
}

.search-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(180px, 240px) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.9);
  padding: 10px;
}

.search-bar label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
  padding: 0 6px;
}

.search-bar input,
.search-bar select {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.search-bar input:focus,
.search-bar select:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(15, 95, 76, 0.15);
  outline: none;
}

.search-bar button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--forest);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 0 16px;
}

.search-bar button:hover {
  background: var(--forest-dark);
}

.sync-error {
  border-left: 4px solid var(--brick);
  background: rgba(169, 67, 50, 0.08);
  color: #7f2b21;
  font-weight: 800;
  margin-bottom: 18px;
  padding: 10px 12px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr));
  gap: 18px;
}

.book-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.92);
  box-shadow: 0 12px 32px rgba(32, 34, 38, 0.08);
  padding: 16px;
}

.cover-frame {
  aspect-ratio: 2 / 3;
  width: 100%;
  align-self: start;
  overflow: hidden;
  border-radius: 6px;
  background: #ded7cd;
  box-shadow: 0 10px 24px rgba(32, 34, 38, 0.18);
}

.cover-frame img,
.cover-placeholder {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-placeholder {
  background:
    linear-gradient(135deg, rgba(15, 95, 76, 0.9), rgba(169, 67, 50, 0.8)),
    #ddd;
}

.book-details {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
}

.book-details h2 {
  margin-bottom: 3px;
  font-size: clamp(1.22rem, 3vw, 1.7rem);
  line-height: 1.08;
}

.book-author {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.book-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.book-meta div {
  min-width: 0;
  border-left: 3px solid var(--gold);
  padding-left: 9px;
}

.book-meta dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.book-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.description {
  margin-bottom: 0;
  color: #454743;
}

.download-link {
  width: fit-content;
  margin-top: auto;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
}

.book-actions .ghost-button,
.book-actions .download-link {
  min-width: 118px;
}

.book-dialog {
  width: min(680px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  padding: 20px;
}

.book-dialog::backdrop {
  background: rgba(32, 34, 38, 0.5);
}

.book-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.book-dialog-header h3 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  line-height: 1.08;
}

.book-dialog-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.book-dialog-meta div {
  min-width: 0;
  border-left: 3px solid var(--gold);
  padding-left: 10px;
}

.book-dialog-meta dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.book-dialog-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.book-dialog-description {
  margin: 8px 0 0;
  color: #454743;
}

.book-dialog-summary {
  margin-top: 18px;
}

.book-dialog-summary .eyebrow {
  margin-bottom: 0;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.8);
  padding: 32px;
}

.empty-state h2 {
  margin: 0;
}

.studio-shell {
  width: min(1320px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0;
  margin: 16px auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(17, 18, 20, 0.92);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.studio-rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.studio-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.studio-brand-mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #20b38d;
  color: #0f1816;
  font-weight: 900;
}

.studio-nav {
  display: grid;
  gap: 8px;
}

.studio-nav-item {
  display: flex;
  min-height: 42px;
  align-items: center;
  border-radius: 10px;
  padding: 0 14px;
  color: rgba(244, 242, 237, 0.72);
  text-decoration: none;
}

.studio-nav-item-active {
  background: rgba(255, 255, 255, 0.09);
  color: #fffdfa;
}

.studio-main {
  padding: 28px;
}

.studio-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.studio-page .library-count,
.studio-page .book-author,
.studio-page .book-meta dt,
.studio-page .search-bar label {
  color: rgba(244, 242, 237, 0.68);
}

.studio-page .eyebrow {
  color: #ff8f6b;
}

.studio-page .ghost-button {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #fffdfa;
}

.studio-page .ghost-button:hover {
  border-color: rgba(32, 179, 141, 0.5);
}

.studio-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.studio-section-head h2 {
  margin: 0;
  font-size: 1.3rem;
}

.studio-spotlight {
  margin-bottom: 28px;
}

.studio-spotlight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.studio-spotlight-card {
  position: relative;
  min-height: 178px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: #181a1d;
}

.studio-spotlight-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.studio-spotlight-copy {
  position: absolute;
  inset: auto 0 0 0;
  padding: 18px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.78));
}

.studio-spotlight-copy h3,
.studio-spotlight-copy p {
  margin: 0;
}

.studio-spotlight-copy h3 {
  margin-bottom: 4px;
  font-size: 1.2rem;
}

.studio-spotlight-copy p {
  color: rgba(244, 242, 237, 0.84);
}

.studio-spotlight-badge {
  display: inline-flex;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(32, 179, 141, 0.18);
  color: #7ce3c8;
  padding: 4px 10px;
  font-size: 0.84rem;
  font-weight: 800;
}

.studio-spotlight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.studio-spotlight-actions .ghost-button,
.studio-spotlight-actions .download-link {
  min-width: 110px;
}

.studio-library {
  display: grid;
  gap: 18px;
}

.studio-page .search-bar {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.studio-page .search-bar input,
.studio-page .search-bar select {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: #fffdfa;
}

.studio-page .search-bar button,
.studio-page .download-link {
  background: #20b38d;
  color: #0f1816;
}

.studio-page .search-bar button:hover,
.studio-page .download-link:hover {
  background: #199978;
}

.studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.studio-tile {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
}

.studio-cover {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.studio-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.studio-copy h3,
.studio-copy p {
  margin: 0;
}

.studio-copy h3 {
  font-size: 1.05rem;
  line-height: 1.2;
}

.studio-author {
  margin-top: 4px;
  color: rgba(244, 242, 237, 0.78);
  font-weight: 700;
}

.studio-meta,
.studio-rating {
  margin-top: 6px;
  color: rgba(244, 242, 237, 0.66);
  font-size: 0.9rem;
}

.studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.studio-actions .ghost-button,
.studio-actions .download-link {
  min-width: 110px;
}

@media (max-width: 720px) {
  .library-header {
    align-items: stretch;
    flex-direction: column;
  }

  .library-header form,
  .ghost-button {
    width: 100%;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions form {
    flex: 1;
  }

  .search-bar {
    grid-template-columns: 1fr;
  }

  .search-bar label {
    padding: 0;
  }

  .book-card {
    grid-template-columns: 108px 1fr;
    gap: 14px;
    padding: 12px;
  }

  .book-meta {
    grid-template-columns: 1fr;
  }

  .book-dialog-meta {
    grid-template-columns: 1fr;
  }

  .studio-shell {
    grid-template-columns: 1fr;
  }

  .studio-rail {
    gap: 18px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .studio-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .studio-header {
    flex-direction: column;
  }

  .studio-spotlight-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .book-card {
    grid-template-columns: 1fr;
  }

  .cover-frame {
    max-width: 168px;
  }

  .download-link {
    width: 100%;
  }

  .book-actions {
    flex-direction: column;
  }

  .book-actions .ghost-button,
  .book-actions .download-link {
    width: 100%;
  }

  .book-dialog {
    padding: 16px;
  }

  .book-dialog-header {
    flex-direction: column;
  }

  .studio-main {
    padding: 18px;
  }

  .studio-nav {
    grid-template-columns: 1fr;
  }

  .studio-actions {
    flex-direction: column;
  }

  .studio-actions .ghost-button,
  .studio-actions .download-link {
    width: 100%;
  }

  .studio-spotlight-actions {
    flex-direction: column;
  }

  .studio-spotlight-actions .ghost-button,
  .studio-spotlight-actions .download-link {
    width: 100%;
  }
}
