@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,500;14..32,600;14..32,700;14..32,800&display=swap");

:root {
  --ink: #2e3335;
  --admin-bg: #686b6d;
  --accent: #be1e3c;
  --accent-hover: #d8274b;
  --accent-soft: #fdecef;
  --muted: rgba(46, 51, 53, 0.62);
  --panel-bg: #ffffff;
  --surface: #f5f6f6;
  --line: rgba(46, 51, 53, 0.12);
  --line-strong: rgba(46, 51, 53, 0.24);
  --shadow: 0 18px 48px rgba(46, 51, 53, 0.1);
}

:root[data-theme="nextsense"] {
  --ink: #171c2f;
  --admin-bg: #aaa8ff;
  --accent: #4a48a8;
  --accent-hover: #171c2f;
  --accent-soft: rgba(170, 168, 255, 0.22);
  --muted: rgba(23, 28, 47, 0.62);
  --panel-bg: #fffdf9;
  --surface: #f6f1eb;
  --line: rgba(23, 28, 47, 0.12);
  --line-strong: rgba(23, 28, 47, 0.22);
  --shadow: 0 22px 58px rgba(23, 28, 47, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Inter", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(190, 30, 60, 0.08), transparent 32%),
    linear-gradient(180deg, #f8f8f8 0%, #eceeee 100%);
}

:root[data-theme="nextsense"] body {
  background:
    radial-gradient(circle at 14% 0%, rgba(170, 168, 255, 0.28), transparent 26%),
    radial-gradient(circle at 86% 10%, rgba(235, 225, 215, 0.86), transparent 28%),
    linear-gradient(180deg, #fffcf7 0%, #f6f0ea 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

:root[data-theme="nextsense"] .topbar {
  background: rgba(255, 253, 249, 0.9);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 14px;
  color: white;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #8f182c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

:root[data-theme="nextsense"] .brand-mark {
  color: var(--ink);
  background: #aaa8ff;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand p,
.eyebrow,
.panel-title span,
.ebook-tab span,
.prompt-number,
#copyStatus,
.stats-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 800;
  line-height: 1;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
}

.search {
  display: grid;
  gap: 7px;
  width: min(480px, 38vw);
}

.search span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

input {
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: white;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(190, 30, 60, 0.12);
}

.ghost,
.copy-btn,
.save-btn,
.secondary,
.primary {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 800;
}

.ghost {
  color: var(--accent);
  background: var(--accent-soft);
}

:root[data-theme="nextsense"] .ghost {
  color: var(--accent);
  background: rgba(170, 168, 255, 0.2);
}

.primary,
.copy-btn {
  color: white;
  background: var(--accent);
}

.secondary,
.save-btn {
  color: var(--ink);
  background: var(--surface);
}

.save-btn[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.copy-btn:hover,
.primary:hover {
  background: var(--accent-hover);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 340px;
  gap: 18px;
  padding: 18px;
  min-height: calc(100vh - 188px);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  padding: 14px 18px 0;
}

.stats-strip article {
  display: grid;
  gap: 6px;
  min-height: 78px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(46, 51, 53, 0.06);
}

.stats-strip strong {
  font-size: 28px;
  line-height: 1;
}

.ebook-panel,
.context-panel,
.prompt-workspace {
  min-width: 0;
}

.ebook-panel,
.context-panel,
.prompt-workspace {
  border: 1px solid rgba(23, 28, 47, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-title,
.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.ebook-list {
  display: grid;
  gap: 10px;
  height: calc(100vh - 275px);
  overflow: auto;
  padding: 12px;
}

.ebook-tab {
  display: grid;
  gap: 10px;
  min-height: 184px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
  color: var(--ink);
  background: var(--panel-bg);
}

.ebook-tab strong {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.18;
}

.cover-art {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  align-content: end;
  gap: 8px;
  min-height: 210px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background:
    radial-gradient(circle at 74% 12%, rgba(190, 30, 60, 0.34), transparent 23%),
    linear-gradient(140deg, #ffffff 0%, #f2f3f3 52%, #dfe2e3 100%);
}

:root[data-theme="nextsense"] .cover-art {
  background:
    radial-gradient(circle at 74% 12%, rgba(170, 168, 255, 0.68), transparent 23%),
    linear-gradient(140deg, #fffdf9 0%, #eee9ff 52%, #ebe1d7 100%);
}

.cover-art::before {
  content: "";
  position: absolute;
  inset: 16px auto auto 16px;
  width: 92px;
  height: 92px;
  border: 1px solid rgba(46, 51, 53, 0.18);
  border-radius: 50%;
  z-index: -1;
}

.cover-art::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -52px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: rgba(190, 30, 60, 0.14);
  z-index: -1;
}

.cover-art.notebook {
  background:
    radial-gradient(circle at 78% 14%, rgba(104, 107, 109, 0.44), transparent 25%),
    linear-gradient(145deg, #ffffff 0%, #eef0f0 54%, #cfd4d6 100%);
}

:root[data-theme="nextsense"] .cover-art.notebook {
  background:
    radial-gradient(circle at 78% 14%, rgba(170, 168, 255, 0.82), transparent 24%),
    linear-gradient(145deg, #f4f1ff 0%, #fffdf9 54%, #e8e1ff 100%);
}

.cover-art.ideas {
  background:
    radial-gradient(circle at 74% 12%, rgba(190, 30, 60, 0.5), transparent 23%),
    linear-gradient(140deg, #fff7f8 0%, #f5dfe4 48%, #c94a61 100%);
}

:root[data-theme="nextsense"] .cover-art.ideas {
  background:
    radial-gradient(circle at 74% 12%, rgba(170, 168, 255, 0.7), transparent 23%),
    linear-gradient(140deg, #fffdf9 0%, #eee9ff 50%, #ded7cc 100%);
}

.cover-art.business {
  background:
    radial-gradient(circle at 76% 13%, rgba(47, 94, 157, 0.4), transparent 24%),
    linear-gradient(140deg, #ffffff 0%, #e8edf4 48%, #9dadc3 100%);
}

:root[data-theme="nextsense"] .cover-art.business {
  background:
    radial-gradient(circle at 76% 13%, rgba(170, 168, 255, 0.66), transparent 24%),
    linear-gradient(140deg, #fff8ee 0%, #f1eddf 48%, #e7e5ff 100%);
}

.cover-art.ai {
  background:
    radial-gradient(circle at 76% 13%, rgba(104, 107, 109, 0.42), transparent 24%),
    radial-gradient(circle at 18% 18%, rgba(190, 30, 60, 0.18), transparent 28%),
    linear-gradient(140deg, #ffffff 0%, #eef0f0 48%, #bfc4c7 100%);
}

:root[data-theme="nextsense"] .cover-art.ai {
  background:
    radial-gradient(circle at 76% 13%, rgba(170, 168, 255, 0.56), transparent 24%),
    radial-gradient(circle at 18% 18%, rgba(235, 225, 215, 0.7), transparent 28%),
    linear-gradient(140deg, #fffdf9 0%, #f6f1eb 48%, #e3e1ff 100%);
}

.cover-chip {
  width: max-content;
  padding: 7px 11px;
  border-radius: 999px;
  color: #fffdf9;
  background: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.cover-orbit {
  position: absolute;
  top: 26px;
  right: 28px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 14px rgba(190, 30, 60, 0.12);
}

:root[data-theme="nextsense"] .cover-orbit {
  background: #aaa8ff;
  box-shadow: 0 0 0 14px rgba(170, 168, 255, 0.2);
}

.cover-art strong {
  max-width: 84%;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.04;
}

.cover-art span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.cover-art.mini {
  min-height: 104px;
  max-height: 104px;
  padding: 12px;
  border-radius: 10px;
}

.cover-art.mini .cover-orbit {
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  box-shadow: 0 0 0 8px rgba(190, 30, 60, 0.12);
}

.cover-art.mini .cover-chip {
  display: none;
}

.cover-art.mini strong {
  max-width: 84%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 16px;
  line-height: 1.08;
}

.cover-art.mini span {
  font-size: 10px;
}

.slide-cover {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 240px;
  aspect-ratio: 6045200 / 8674100;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(190, 30, 60, 0.18), transparent 36%),
    #eef0f0;
}

.slide-cover.mini {
  min-height: 118px;
  border-radius: 10px;
}

.cover-shape {
  position: absolute;
  overflow: hidden;
}

.cover-text {
  padding: 0.12em;
  white-space: pre-wrap;
  line-height: 1.08;
  font-family: "Inter", Arial, sans-serif;
}

.cover-image {
  object-fit: cover;
}

.cover-box {
  opacity: 0.96;
}

.ebook-tab[aria-current="true"] {
  border-color: rgba(190, 30, 60, 0.32);
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

.prompt-workspace {
  display: grid;
  grid-template-rows: auto 1fr;
}

.workspace-head {
  background:
    linear-gradient(90deg, rgba(190, 30, 60, 0.08), transparent 48%),
    rgba(255, 255, 255, 0.9);
}

:root[data-theme="nextsense"] .workspace-head {
  background:
    linear-gradient(90deg, rgba(170, 168, 255, 0.24), transparent 48%),
    rgba(255, 253, 249, 0.9);
}

.workspace-head h2 {
  margin-top: 5px;
  font-size: clamp(30px, 3vw, 46px);
  font-weight: 800;
  line-height: 1;
}

.active-cover {
  margin-top: 16px;
  max-width: 560px;
}

.view-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(46, 51, 53, 0.06);
}

.view-switch button {
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.view-switch button[aria-pressed="true"] {
  color: #fffdf9;
  background: var(--ink);
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  align-content: start;
  height: calc(100vh - 340px);
  overflow: auto;
  padding: 15px;
}

.tag-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.tag-chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: white;
  font-weight: 700;
}

.tag-chip[aria-pressed="true"] {
  border-color: rgba(190, 30, 60, 0.38);
  color: var(--accent);
  background: var(--accent-soft);
}

.tag-chip span {
  margin-left: 4px;
  color: var(--muted);
}

.prompt-grid.compact {
  grid-template-columns: 1fr;
}

.prompt-card {
  display: grid;
  gap: 14px;
  min-height: 250px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, #ffffff, #fafafa),
    var(--panel-bg);
}

.prompt-card[aria-current="true"] {
  border-color: rgba(190, 30, 60, 0.48);
  box-shadow: 0 18px 38px rgba(190, 30, 60, 0.12);
}

.prompt-card.is-favorite {
  box-shadow:
    inset 0 0 0 1px rgba(190, 30, 60, 0.18),
    0 18px 38px rgba(46, 51, 53, 0.08);
}

.prompt-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.prompt-tags,
.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.prompt-tags span,
.modal-tags span {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 800;
}

.prompt-card h3 {
  margin-top: 7px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.08;
}

.prompt-card pre {
  max-height: 300px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink);
  font: 15px/1.55 "Inter", Arial, sans-serif;
}

.prompt-grid.compact .prompt-card {
  min-height: auto;
}

.prompt-grid.compact .prompt-card pre {
  max-height: 150px;
}

.context-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.context-card h3 {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.08;
}

.context-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.58;
  white-space: pre-wrap;
}

.selected-copy {
  max-height: 280px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  white-space: pre-wrap;
  font: 14px/1.55 "Inter", Arial, sans-serif;
}

.detail-modal {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
}

.detail-modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.modal-shell {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.24);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  font-size: 24px;
  line-height: 1;
}

.modal-shell h2 {
  max-width: calc(100% - 48px);
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
}

#modalText {
  max-height: 50vh;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font: 15px/1.6 "Inter", Arial, sans-serif;
}

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

#copyStatus {
  min-height: 34px;
  padding: 0 18px 16px;
  color: var(--accent);
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 30px;
  border: 1px dashed rgba(190, 30, 60, 0.32);
  border-radius: 12px;
  background: white;
}

.empty-state p {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 260px 1fr;
  }

  .context-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
  }

  .ebook-list,
  .prompt-grid {
    height: auto;
    max-height: none;
  }
}
