@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Noto+Sans+SC:wght@400;500;700&display=swap");

:root {
  --paper: #f7f1e8;
  --paper-2: #efe2d0;
  --ink: #121212;
  --ink-soft: #4f4a43;
  --panel: rgba(255, 250, 243, 0.84);
  --line: rgba(18, 18, 18, 0.12);
  --accent: #df5d38;
  --accent-2: #0f7c73;
  --shadow: 0 18px 50px rgba(58, 39, 24, 0.12);
}

* {
  box-sizing: border-box;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

html {
  min-height: 100%;
  background: #fff8ef;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  position: relative;
  isolation: isolate;
  background: transparent;
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  overflow-x: hidden;
}

body.network-busy {
  cursor: progress;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at top left, rgba(223, 93, 56, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(15, 124, 115, 0.16), transparent 24%),
    linear-gradient(180deg, #fff8ef 0%, var(--paper) 100%);
  background-repeat: no-repeat;
  background-position: top left, bottom right, center top;
  background-size: 100% 100%, 100% 100%, 100% 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1480px, calc(100vw - 28px));
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 max(42px, env(safe-area-inset-bottom));
}

.main-nav,
.panel {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: 220px minmax(0, 1fr);
}

.workspace.auth-locked {
  grid-template-columns: 1fr;
}

.workspace.auth-locked .main-nav {
  display: none;
}

.workspace.auth-locked .view-stack {
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.mobile-topbar,
.mobile-nav-head,
.mobile-nav-overlay {
  display: none;
}

.mobile-topbar {
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.mobile-topbar strong,
.mobile-nav-head strong {
  font-size: 16px;
  line-height: 1.1;
}

.mobile-menu-button,
.mobile-nav-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  padding: 0;
  border-radius: 14px;
  background: rgba(18, 18, 18, 0.08);
  color: var(--ink);
  box-shadow: none;
}

.mobile-menu-button {
  display: inline-grid;
  gap: 4px;
  align-content: center;
  justify-items: center;
}

.mobile-menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.mobile-nav-head {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-nav-close {
  font-size: 24px;
  line-height: 1;
}

.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 38;
  border: 0;
  padding: 0;
  background: rgba(18, 18, 18, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

body.mobile-nav-open {
  overflow: hidden;
}

body.mobile-nav-open .mobile-nav-overlay {
  opacity: 1;
  pointer-events: auto;
}

.main-nav {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 10px;
  align-self: start;
  padding: 16px;
  border-radius: 24px;
}

.nav-account {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(18, 18, 18, 0.05);
}

.nav-account strong {
  display: block;
  font-size: 18px;
}

.nav-logout {
  width: 100%;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(15, 124, 115, 0.12);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
}

.nav-link {
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  text-align: left;
  background: rgba(18, 18, 18, 0.06);
  color: var(--ink);
  font-weight: 700;
}

.nav-link.active {
  background: linear-gradient(135deg, var(--accent), #f48d4f);
  color: white;
}

.view {
  display: none;
  gap: 16px;
}

.view.active {
  display: grid;
}

.view-header h2,
.panel-head h3 {
  margin: 0;
}

.view-header p,
.panel-head p {
  margin: 8px 0 0;
  color: var(--ink-soft);
}

.with-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}

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

.panel {
  border-radius: 28px;
  padding: 20px;
}

.auth-shell {
  min-height: calc(100vh - 90px);
  display: grid;
  place-items: center;
}

.auth-card {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.auth-header h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 0.95;
}

.auth-header p {
  margin: 10px 0 0;
  color: var(--ink-soft);
}

.eyebrow {
  margin: 0 0 10px !important;
  color: var(--accent) !important;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 800;
}

.auth-switch {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-switch button {
  background: rgba(18, 18, 18, 0.08);
  color: var(--ink);
}

.auth-switch button.active,
.auth-switch button.ghost.active {
  background: linear-gradient(135deg, var(--accent), #f48d4f);
  color: white;
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
}

.keyword-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
}

.keyword-main {
  display: grid;
  gap: 18px;
}

.keyword-sidebar {
  position: sticky;
  top: 18px;
  align-self: start;
}

.keyword-sidebar-panel {
  position: relative;
  z-index: 18;
  display: grid;
  gap: 16px;
}

.keyword-selected-panel {
  margin-top: 4px;
}

.keyword-actions-stack {
  display: grid;
  gap: 10px;
}

.keyword-actions-stack button {
  width: 100%;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.keyword-toolbar {
  position: relative;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.inline-form {
  display: flex;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

.tag-autocomplete-field {
  position: relative;
  z-index: 19;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(18, 18, 18, 0.14);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

textarea {
  resize: vertical;
}

button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent), #f48d4f);
  color: white;
  font-weight: 700;
  text-decoration: none;
  transition: transform 160ms ease, opacity 160ms ease;
}

button:hover,
.download-link:hover {
  transform: translateY(-1px);
}

button.is-busy,
.download-link.is-busy {
  pointer-events: none;
  opacity: 0.78;
  transform: none;
}

button.is-busy::after,
.download-link.is-busy::after {
  content: "";
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
}

.cover-button.is-busy {
  position: relative;
  overflow: hidden;
}

.cover-button.is-busy::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(18, 18, 18, 0.16);
}

.cover-button.is-busy::after {
  position: absolute;
  top: calc(50% - 7px);
  left: calc(50% - 7px);
  margin: 0;
}

button.ghost,
.download-link.ghost,
button.secondary,
.download-link.secondary {
  background: rgba(18, 18, 18, 0.08);
  color: var(--ink);
}

.form-actions,
.toolbar-actions,
.card-actions,
.album-actions,
.chapter-actions,
.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.wide {
  grid-column: 1 / -1;
}

.card-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.pagination {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
}

.pagination:empty {
  display: none;
}

.pagination-link {
  min-width: 48px;
  padding: 10px 14px;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
}

.pagination-link.edge {
  min-width: 90px;
}

.pagination-link.active {
  background: linear-gradient(135deg, var(--accent), #f48d4f);
  color: white;
}

.comic-card {
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(18, 18, 18, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 241, 229, 0.92));
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.comic-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 34px rgba(46, 24, 10, 0.16);
}

.comic-card > button.cover-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}

.comic-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: var(--paper-2);
}

.card-body {
  padding: 14px;
}

.card-body h3,
.album-sheet h3,
.photo-sheet h3 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
}

.tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tags span {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  background: rgba(15, 124, 115, 0.1);
  color: var(--accent-2);
}

.detail-surface {
  min-height: 220px;
  border-radius: 22px;
  border: 1px dashed rgba(18, 18, 18, 0.14);
  padding: 18px;
  background: rgba(255, 255, 255, 0.52);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 120px;
  color: var(--ink-soft);
}

.album-sheet,
.photo-sheet {
  display: grid;
  gap: 18px;
}

.album-grid,
.photo-grid,
.reader-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: 260px minmax(0, 1fr);
}

.cover-frame,
.photo-cover {
  display: grid;
  place-items: center;
  border-radius: 22px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.cover-frame img,
.photo-cover img {
  width: 100%;
  max-height: 70vh;
  border-radius: 22px;
  display: block;
  object-fit: contain;
  box-shadow: 0 16px 28px rgba(30, 13, 5, 0.16);
}

.chapter-list,
.photo-list {
  display: grid;
  gap: 12px;
}

.chapter-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  align-items: center;
  border-radius: 16px;
  border: 1px solid rgba(18, 18, 18, 0.08);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.74);
}

.reader-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.reader-toolbar p {
  margin: 8px 0 0;
  color: var(--ink-soft);
}

.chapter-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(18, 18, 18, 0.08);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.chapter-item.active {
  background: linear-gradient(135deg, rgba(223, 93, 56, 0.14), rgba(244, 141, 79, 0.18));
  border-color: rgba(223, 93, 56, 0.28);
}

.keyword-groups {
  display: grid;
  gap: 16px;
}

.keyword-index-panel {
  position: sticky;
  top: 86px;
  z-index: 8;
}

.keyword-index {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.keyword-index-item {
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid rgba(18, 18, 18, 0.1);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(30, 13, 5, 0.06);
}

.keyword-index-item:not(.disabled):hover {
  border-color: rgba(223, 93, 56, 0.3);
  transform: translateY(-1px);
}

.keyword-index-item.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.keyword-group {
  display: grid;
  gap: 14px;
  scroll-margin-top: 146px;
}

.keyword-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.keyword-group-head span {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.keyword-grid,
.keyword-selected {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.keyword-grid {
  padding-right: 4px;
}

.keyword-chip,
.keyword-pill {
  border: 1px solid rgba(18, 18, 18, 0.1);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-weight: 700;
}

.keyword-chip.active,
.keyword-pill {
  background: linear-gradient(135deg, var(--accent), #f48d4f);
  border-color: transparent;
  color: white;
}

.keyword-selected {
  min-height: 44px;
}

.keyword-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 12;
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(18, 18, 18, 0.1);
  background: rgba(255, 250, 243, 0.96);
  box-shadow: 0 18px 40px rgba(58, 39, 24, 0.14);
  backdrop-filter: blur(10px);
}

.keyword-suggestions.hidden {
  display: none;
}

.keyword-suggestion-item {
  justify-content: flex-start;
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-weight: 700;
}

.keyword-suggestion-empty {
  padding: 12px 14px;
  color: var(--ink-soft);
}

.empty-state.compact {
  min-height: 44px;
  justify-content: start;
}

.reader-stage {
  min-height: 560px;
}

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

.admin-invite-list {
  display: grid;
  gap: 12px;
}

.admin-invite-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  align-items: center;
  border-radius: 16px;
  border: 1px solid rgba(18, 18, 18, 0.08);
  padding: 14px;
  background: rgba(255, 255, 255, 0.76);
}

.admin-invite-row p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.invite-code {
  display: block;
  word-break: break-all;
}

.admin-invite-meta {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.reader-images {
  display: grid;
  gap: 18px;
}

.reader-images img {
  width: 100%;
  display: block;
  border-radius: 18px;
  background: var(--paper-2);
}

.chat-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
}

.chat-sidebar-panel {
  position: sticky;
  top: 18px;
}

.chat-connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(18, 18, 18, 0.08);
  color: var(--ink);
  font-weight: 800;
}

.chat-connection-badge::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(18, 18, 18, 0.28);
}

.chat-connection-badge.connected {
  background: rgba(15, 124, 115, 0.12);
  color: var(--accent-2);
}

.chat-connection-badge.connected::before {
  background: var(--accent-2);
  box-shadow: 0 0 0 6px rgba(15, 124, 115, 0.12);
}

.chat-connection-badge.connecting {
  background: rgba(223, 93, 56, 0.12);
  color: var(--accent);
}

.chat-connection-badge.connecting::before {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(223, 93, 56, 0.12);
}

.chat-online-list {
  display: grid;
  gap: 10px;
}

.chat-online-user {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(18, 18, 18, 0.08);
  font-weight: 700;
}

.chat-online-user::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-2);
  box-shadow: 0 0 0 5px rgba(15, 124, 115, 0.12);
}

.chat-online-user.self {
  border-color: rgba(223, 93, 56, 0.24);
  background: linear-gradient(135deg, rgba(223, 93, 56, 0.12), rgba(244, 141, 79, 0.16));
}

.chat-panel {
  display: grid;
  gap: 16px;
}

.chat-messages {
  display: grid;
  gap: 10px;
  min-height: 58vh;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  padding-right: 8px;
}

.chat-message {
  display: flex;
  justify-content: flex-start;
}

.chat-message.self {
  justify-content: flex-end;
}

.chat-bubble {
  width: fit-content;
  max-width: min(560px, 78%);
  min-width: 180px;
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(18, 18, 18, 0.08);
  box-shadow: 0 10px 22px rgba(58, 39, 24, 0.07);
}

.chat-message.self .chat-bubble {
  background: linear-gradient(135deg, rgba(223, 93, 56, 0.18), rgba(244, 141, 79, 0.24));
  border-color: rgba(223, 93, 56, 0.18);
}

.chat-message-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.chat-message-author {
  font-size: 13px;
  font-weight: 800;
}

.chat-message-time {
  color: var(--ink-soft);
  font-size: 12px;
}

.chat-message-text {
  line-height: 1.6;
  word-break: break-word;
  color: var(--ink);
}

.chat-embeds {
  display: grid;
  gap: 8px;
}

.chat-embed-card {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 84px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(18, 18, 18, 0.08);
  background: rgba(18, 18, 18, 0.04);
}

.chat-embed-copy {
  display: grid;
  gap: 6px;
}

.chat-embed-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chat-embed-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.chat-embed-description {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}

.chat-embed-cover {
  width: 84px;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  object-fit: cover;
  background: var(--paper-2);
  box-shadow: 0 10px 18px rgba(30, 13, 5, 0.12);
}

.chat-embed-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-embed-actions button {
  padding: 8px 12px;
  border-radius: 12px;
}

.chat-form {
  display: grid;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(18, 18, 18, 0.08);
}

.chat-form textarea {
  min-height: 92px;
}

.chat-form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.chat-form-actions span {
  color: var(--ink-soft);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(440px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 18px;
  color: white;
  background: rgba(18, 18, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 30px rgba(18, 18, 18, 0.18);
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  filter: blur(6px);
  pointer-events: none;
  transition:
    opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 220ms ease,
    background 180ms ease;
  will-change: opacity, transform, filter;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

.toast.toast-leaving {
  opacity: 0;
  transform: translateY(10px) scale(0.99);
  filter: blur(4px);
}

.activity-indicator {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 16px;
  border-radius: 999px;
  color: white;
  background: rgba(18, 18, 18, 0.9);
  box-shadow: 0 16px 30px rgba(18, 18, 18, 0.18);
}

.activity-indicator::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-right-color: white;
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
}

.floating-top-button {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 30;
  box-shadow: 0 16px 30px rgba(18, 18, 18, 0.18);
}

.activity-indicator.hidden,
.toast.hidden {
  display: none;
}

.floating-top-button.hidden {
  display: none;
}

@media (max-width: 1120px) {
  .workspace,
  .keyword-layout,
  .chat-layout,
  .reader-layout,
  .album-grid,
  .photo-grid,
  .admin-grid,
  .form-grid,
  .form-grid.compact,
  .keyword-toolbar {
    grid-template-columns: 1fr;
  }

  .main-nav {
    position: static;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .inline-form,
  .reader-toolbar,
  .with-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .keyword-sidebar {
    position: static;
    order: -1;
  }

  .keyword-index-panel {
    position: static;
  }

  .chat-sidebar-panel {
    position: static;
  }

  .chat-form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-embed-card {
    grid-template-columns: 1fr;
  }

  .chat-embed-cover {
    width: 100%;
    max-width: 180px;
    aspect-ratio: 3 / 4;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 16px, 100%);
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .workspace {
    gap: 12px;
  }

  .mobile-topbar {
    display: flex;
    position: sticky;
    top: max(12px, env(safe-area-inset-top));
    z-index: 37;
  }

  .main-nav {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 40;
    width: min(320px, calc(100vw - 28px));
    gap: 10px;
    padding: 14px;
    border-radius: 20px;
    grid-template-columns: 1fr;
    align-content: start;
    overflow-y: auto;
    transform: translateX(calc(-100% - 24px));
    transition: transform 220ms ease;
  }

  body.mobile-nav-open .main-nav {
    transform: translateX(0);
  }

  .mobile-nav-head {
    display: flex;
  }

  .nav-account {
    padding: 12px;
  }

  .nav-account strong {
    font-size: 16px;
  }

  .nav-link {
    min-height: 46px;
    padding: 12px 14px;
    border-radius: 14px;
    text-align: left;
  }

  .panel {
    padding: 16px;
    border-radius: 22px;
  }

  .view {
    gap: 12px;
  }

  .view-header p,
  .panel-head p {
    font-size: 14px;
    line-height: 1.5;
  }

  .card-grid {
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .card-body {
    padding: 12px;
  }

  .card-actions,
  .album-actions,
  .chapter-actions,
  .toolbar-actions,
  .form-actions,
  .view-actions,
  .admin-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .card-actions > *,
  .album-actions > *,
  .chapter-actions > *,
  .toolbar-actions > *,
  .form-actions > *,
  .view-actions > *,
  .admin-actions > * {
    width: 100%;
  }

  .chapter-row {
    grid-template-columns: 1fr;
  }

  .pagination {
    gap: 8px;
    margin-top: 14px;
  }

  .pagination-link {
    min-width: 42px;
    padding: 8px 12px;
  }

  .pagination-link.edge {
    min-width: 74px;
  }

  .keyword-index {
    gap: 8px;
  }

  .keyword-index-item {
    min-width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .keyword-chip,
  .keyword-pill {
    padding: 8px 12px;
  }

  .reader-images {
    gap: 12px;
  }

  .reader-images img {
    border-radius: 14px;
  }

  .chat-messages {
    min-height: 44vh;
    max-height: none;
    padding-right: 0;
  }

  .chat-bubble {
    max-width: 92%;
    min-width: 0;
  }

  .chat-embed-actions button {
    flex: 1 1 120px;
  }

  .chat-form textarea {
    min-height: 76px;
  }

	.toast {
	  right: 12px;
	  left: 12px;
	  top: auto;
	  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 64px);
	  max-width: none;
	}
	
	.activity-indicator {
	  top: calc(max(12px, env(safe-area-inset-top)) + 72px);
	  right: 12px;
	  left: auto;
	  bottom: auto;
	  width: max-content;
	  max-width: calc(100vw - 24px);
	  padding: 10px 14px;
	  border-radius: 999px;
	}



	.floating-top-button {
	  left: auto;
	  right: 12px;
	  bottom: max(12px, env(safe-area-inset-bottom));
	}
	
	body[data-view="reader"] .floating-top-button {
	  top: calc(max(12px, env(safe-area-inset-top)) + 72px);
	  right: 12px;
	  bottom: auto;
	  left: auto;
	}


@media (max-width: 560px) {
  .main-nav {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
    border-radius: 20px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .comic-card {
    border-radius: 18px;
  }

  .cover-frame,
  .photo-cover {
    padding: 10px;
  }

  .cover-frame img,
  .photo-cover img {
    max-height: 58vh;
    border-radius: 18px;
  }

  .chat-embed-card {
    grid-template-columns: 1fr;
  }

  .chat-embed-cover {
    width: 100%;
    max-width: 140px;
  }

  .chat-form-actions {
    gap: 10px;
  }
}
