.view-container {
  width: min(100%, 1120px);
  padding-top: 24px;
}

.api-panel {
  max-width: 980px;
  margin: 0 auto 16px;
  padding: 14px 18px;
  gap: 8px;
  border-color: #262626;
  background: linear-gradient(180deg, rgba(28, 28, 28, .92), rgba(11, 11, 11, .96));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .24);
}

.api-row {
  grid-template-columns: 96px 128px minmax(0, 1fr) 126px 126px;
  gap: 8px;
  align-items: center;
}

.api-row.api-row-claude {
  grid-template-columns: 96px 128px minmax(0, 1fr) minmax(0, 1fr) 126px 126px;
}

.api-row label {
  font-size: 12px;
}

.api-row input,
.api-row select {
  min-height: 38px;
}

.api-row .button {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.api-panel .muted {
  margin: -2px 0 8px 232px;
  font-size: 12px;
  line-height: 1.3;
}

.api-panel > .row {
  margin-top: 2px !important;
}

.api-panel [data-clear-keys] {
  width: auto;
  min-height: 34px;
}

.admin-page {
  max-width: 1240px;
}

.admin-panel {
  display: grid;
  gap: 16px;
  margin: 0 0 16px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.admin-main {
  min-width: 0;
}

.admin-side-nav {
  position: sticky;
  top: 70px;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #2b2b2b;
  border-radius: 8px;
  background: rgba(18, 18, 18, 0.94);
}

.admin-side-title {
  padding: 4px 6px 8px;
  color: #9a9a9a;
  font-size: 12px;
  font-weight: 800;
}

.admin-side-nav button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #303030;
  border-radius: 8px;
  background: #101010;
  color: #e9e9e9;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.admin-side-nav button:hover {
  border-color: #555;
  background: #161616;
}

.admin-side-nav button.active {
  border-color: #ff3838;
  background: #ff3838;
  color: #fff;
}

.admin-page[data-admin-current-section="features"] [data-admin-group]:not([data-admin-group="features"]),
.admin-page[data-admin-current-section="database"] [data-admin-group]:not([data-admin-group="database"]),
.admin-page[data-admin-current-section="reports"] [data-admin-group]:not([data-admin-group="reports"]),
.admin-page[data-admin-current-section="logs"] [data-admin-group]:not([data-admin-group="logs"]) {
  display: none;
}

.admin-compact-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-compact-actions .button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.admin-report-log-preview {
  min-height: 160px;
}

.admin-panel h2 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: 0;
}

.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-check input {
  width: 16px;
  height: 16px;
}

.admin-form-row,
.admin-filter-row {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px);
  gap: 10px;
  align-items: end;
}

.admin-filter-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 160px 96px;
}

.admin-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 69, 69, 0.45);
  border-radius: 8px;
  background: rgba(255, 45, 45, 0.08);
  color: #ffb0b0;
  font-size: 13px;
  font-weight: 800;
}

.admin-db-usage {
  display: grid;
  gap: 10px;
}

.admin-plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #d8d8d8;
  font-size: 13px;
  font-weight: 800;
}

.admin-plan-row .segmented button.active {
  background: #1f9d55;
  border-color: #1f9d55;
  color: #fff;
}

.admin-db-usage-top,
.admin-db-usage-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-db-usage-top strong {
  font-size: 18px;
}

.admin-db-usage-top span,
.admin-db-usage-bottom {
  color: #b9b9b9;
  font-size: 13px;
  font-weight: 800;
}

.admin-db-bar {
  overflow: hidden;
  height: 12px;
  border: 1px solid #323232;
  border-radius: 999px;
  background: #0b0b0b;
}

.admin-db-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #30d158, #ffd60a, #ff3b30);
}

.admin-row-usage {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-row-usage-item {
  display: grid;
  gap: 8px;
}

.admin-field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #d8d8d8;
  font-weight: 800;
}

.admin-prompt-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.admin-model-prompt-box {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  background: #050505;
  color: #e8e8e8;
  padding: 12px;
  font-size: 14px;
  line-height: 1.6;
}

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

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid #262626;
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.admin-table th,
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #242424;
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: #b9c9ff;
  font-size: 12px;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table select {
  min-height: 36px;
  min-width: 120px;
}

.admin-empty {
  color: #999;
  text-align: center !important;
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.admin-temp-log-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-temp-log-box {
  width: 100%;
  min-height: 220px;
  max-height: 420px;
  resize: vertical;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  background: #050505;
  color: #e8e8e8;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
}

.live-panel {
  margin-top: 0;
  border-bottom: 0;
}

.sidebar-footer {
  margin-top: auto;
}

.side-balance {
  margin-top: 0 !important;
}

.library-head > .button[data-open-auth='login'] {
  display: none;
}

.hero {
  max-width: 980px;
  min-height: 118px;
  margin: 22px auto 26px;
  padding: 22px 24px;
  border: 1px solid #2d2d2d;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 57, 51, .22), rgba(255, 57, 51, 0) 42%),
    linear-gradient(135deg, #27211f, #101010 64%, #181818);
  box-shadow: 0 20px 70px rgba(0, 0, 0, .35);
}

.hero h1 {
  font-size: 25px;
  letter-spacing: 0;
}

.hero p {
  margin: 0;
  color: #b9b9b9;
}

.hero .button {
  margin-right: clamp(16px, 4vw, 72px);
  min-width: 128px;
  box-shadow: 0 12px 28px rgba(255, 57, 51, .22);
}

.library-head {
  max-width: 980px;
  margin: 18px auto 10px;
  align-items: flex-end;
}

.library-head h2 {
  font-size: 24px;
  letter-spacing: 0;
}

.chip-row {
  gap: 9px;
  padding: 12px 0 4px;
}

.chip {
  min-height: 36px;
  padding: 0 15px;
  border-color: #353535;
  background: #101010;
  color: #e7e7e7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}

.chip.active {
  background: #ff3933;
  border-color: #ff3933;
  color: #fff;
}

.notice {
  max-width: 980px;
  margin: 16px auto 24px;
}

.library-section {
  max-width: 980px;
  margin: 30px auto 0;
}

.section-title {
  margin: 0 0 14px;
}

.section-title h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
}

.section-title h2::before {
  content: "";
  width: 7px;
  height: 18px;
  border-radius: 999px;
  background: #ff3933;
  box-shadow: 0 0 20px rgba(255, 57, 51, .5);
}

.section-title span {
  padding: 5px 10px;
  border: 1px solid #2d2d2d;
  border-radius: 999px;
  background: #111;
}

.library-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 16px;
}

.story-card {
  overflow: hidden;
  border-radius: 8px;
  padding: 0 0 10px;
  cursor: pointer;
  transition: transform .18s ease;
}

.story-card:hover {
  transform: translateY(-2px);
}

.story-cover {
  margin-bottom: 9px;
  overflow: hidden;
  border-color: #272727;
  background: #171717;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .28);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

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

.story-card:hover .story-cover {
  transform: translateY(-3px);
  border-color: #575757;
  box-shadow: 0 16px 34px rgba(0, 0, 0, .38);
}

.story-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.story-body .row {
  gap: 5px !important;
}

.story-body h3 {
  margin: 8px 0 6px;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0;
}

.story-body p {
  font-size: 12px;
  color: #9f9f9f;
}

.story-card-creator {
  margin-top: 4px;
  font-size: 12px;
  color: #b6b6b6;
}

.story-card-creator-label {
  color: #f0f0f0;
  font-weight: 900;
}

.story-card-creator-name {
  color: #ffd166;
  font-weight: 900;
}

.story-meta {
  margin-top: 7px;
  font-size: 12px;
  color: #8d8d8d;
}

.tag {
  min-height: 20px;
  padding: 0 6px;
  background: #24272c;
  color: #dbe4f5;
}

.story-report-open {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin-top: 8px;
}

.story-report-open svg,
.story-report-upload svg {
  width: 17px;
  height: 17px;
}

.story-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 52px 20px 30px;
  overflow: auto;
  background: rgba(0, 0, 0, .76);
}

.story-detail-shell {
  overflow: hidden;
  width: min(100%, 760px);
  height: min(860px, calc(100vh - 82px));
  max-height: calc(100vh - 82px);
  display: flex;
  flex-direction: column;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  background: #111;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .42);
}

.story-detail-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

.story-detail-main {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 28px;
  padding: 28px;
  align-items: center;
}

.story-detail-cover {
  width: 220px;
  aspect-ratio: 3 / 4;
  margin: 0;
  padding: 0;
  appearance: none;
  border: 1px solid #383838;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #1a1a1a;
  color: #aaa;
  font-weight: 800;
  cursor: zoom-in;
  caret-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.story-detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.story-detail-cover:focus,
.story-detail-cover:focus-visible {
  outline: none;
}

.story-detail-kicker {
  margin-bottom: 12px;
  color: #c8c8c8;
  font-weight: 900;
}

.story-detail-info h1 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.25;
}

.story-detail-author,
.story-detail-stats {
  color: #a5a5a5;
  font-size: 13px;
}

.story-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 18px 0;
}

.story-detail-tags span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  background: #181818;
  color: #d9d9d9;
  font-size: 12px;
  font-weight: 800;
}

.story-detail-description {
  border-top: 1px solid #2d2d2d;
  padding: 24px 28px;
}

.story-detail-description h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.story-detail-text {
  margin: 0;
  color: #ddd;
  line-height: 1.8;
}

.story-detail-social {
  border-top: 1px solid #2d2d2d;
  padding: 22px 28px 26px;
}

.story-detail-social-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.story-detail-social-head > span {
  color: #bbb;
  font-size: 13px;
  font-weight: 800;
}

.story-comments-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.story-comment {
  border: 1px solid #303030;
  border-radius: 8px;
  padding: 12px 14px;
  background: #171717;
}

.story-comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #aaa;
  font-size: 12px;
}

.story-comment-meta strong {
  color: #fff;
}

.story-comment-body {
  margin: 0;
  color: #ddd;
  line-height: 1.65;
}

.story-detail-text > span,
.story-comment-body > span {
  display: block;
  margin: 0 0 12px;
}

.story-narration {
  color: #929aa4;
}

.story-dialogue-speaker {
  color: #e9e9e9;
  font-weight: 900;
}

.story-dialogue-divider {
  color: #7d7d7d;
  margin: 0 6px;
}

.story-dialogue-text {
  font-weight: 800;
}

.story-inline-image {
  display: block;
  width: min(100%, 680px);
  max-height: 560px;
  margin: 12px 0;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  object-fit: contain;
  background: #080808;
}

.story-comment-author {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.story-creator-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border: 1px solid rgba(255, 63, 57, .55);
  border-radius: 999px;
  background: rgba(255, 63, 57, .14);
  color: #ff7c77;
  font-size: 11px;
  font-weight: 900;
}

.story-comment-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.button.small {
  min-height: 32px;
  padding: 0 11px;
  font-size: 12px;
}

.story-replies {
  display: grid;
  gap: 8px;
  margin: 12px 0 0 14px;
  padding-left: 12px;
  border-left: 2px solid #2c2c2c;
}

.story-reply {
  border: 1px solid #2c2c2c;
  border-radius: 8px;
  padding: 10px 12px;
  background: #111;
}

.story-reply-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.story-reply-form textarea {
  min-height: 72px;
  resize: vertical;
}

.story-reply-form .button {
  justify-self: end;
}

.story-comment-form {
  display: grid;
  gap: 10px;
}

.story-comment-form textarea {
  min-height: 84px;
  resize: vertical;
}

.story-comment-form .button {
  justify-self: end;
}

.story-comment-login {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #303030;
  border-radius: 8px;
  padding: 12px 14px;
  color: #bbb;
  background: #171717;
}

.story-detail-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid #2d2d2d;
  background: rgba(18, 18, 18, .96);
}

.story-detail-actions .button:only-child {
  grid-column: 1 / -1;
}

.story-report-overlay {
  position: fixed;
  inset: 0;
  z-index: 105;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .76);
}

.story-report-dialog {
  width: min(100%, 430px);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  background: #121212;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
}

.story-report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.story-report-head p {
  margin: 0 0 4px;
  color: #a8a8a8;
  font-size: 12px;
  font-weight: 800;
}

.story-report-head h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.35;
}

.story-report-copy {
  margin: 0;
  color: #aaa;
  line-height: 1.6;
}

.story-report-field {
  display: grid;
  gap: 8px;
  color: #f1f1f1;
  font-size: 13px;
  font-weight: 900;
}

.story-report-field textarea {
  min-height: 118px;
  resize: vertical;
}

.story-report-attach {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.story-report-attach div {
  display: grid;
  gap: 4px;
}

.story-report-attach span {
  color: #8f8f8f;
  font-size: 12px;
}

.story-report-upload {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 59, 59, .38);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 59, 59, .18), rgba(255, 59, 59, .06));
  color: #ff7777;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.story-report-upload:hover {
  border-color: rgba(255, 78, 78, .72);
  background: linear-gradient(180deg, rgba(255, 59, 59, .28), rgba(255, 59, 59, .1));
  transform: translateY(-1px);
}

.story-report-upload svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.story-report-upload input {
  display: none;
}

.story-report-submit {
  width: 100%;
  margin-top: 6px;
}

.story-image-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 26px;
  background: rgba(0, 0, 0, .82);
}

.story-image-zoom-dialog {
  position: relative;
  max-width: min(92vw, 900px);
  max-height: 92vh;
}

.story-image-zoom-dialog img {
  max-width: 100%;
  max-height: 92vh;
  display: block;
  border-radius: 4px;
  object-fit: contain;
}

.story-image-zoom-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

#story-builder-static .static-story-intro-field {
  display: grid;
  gap: 8px;
}

#story-builder-static .static-story-intro-head,
.builder-story-intro-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
}

#story-builder-static .static-story-intro-head > div:first-child,
.builder-story-intro-head > div:first-child {
  display: grid;
  gap: 6px;
  min-width: 0;
}

#story-builder-static .static-story-intro-row {
  margin: 0 !important;
  align-self: end;
  white-space: nowrap;
}

#story-builder-static .static-story-intro-row input,
.builder-story-intro-controls .tokenInput {
  width: 96px !important;
  max-width: 96px !important;
  flex: 0 0 96px !important;
  text-align: center;
}

.builder-story-intro-controls {
  align-self: end;
  flex-wrap: nowrap;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .story-detail-overlay {
    align-items: start;
    padding: 22px 12px;
  }

  .story-detail-main {
    grid-template-columns: 1fr;
  }

  .story-detail-cover {
    width: min(100%, 260px);
  }

  #story-builder-static .static-story-intro-head,
  .builder-story-intro-head {
    grid-template-columns: 1fr;
  }

  #story-builder-static .static-story-intro-row,
  .builder-story-intro-controls {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .api-row {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-side-nav {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-side-title {
    grid-column: 1 / -1;
  }

  .admin-panel-head,
  .admin-form-row,
  .admin-filter-row,
  .admin-prompt-grid {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .api-panel .muted {
    margin-left: 0;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero .button {
    margin-right: 0;
  }
}

@media (max-width: 560px) {
  .view-container {
    padding-left: 16px;
    padding-right: 16px;
  }

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