/* ── Layout ─────────────────────────────────────────── */
.dashboard {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  color: var(--ink);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem 1.25rem;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Brand */
.sidebar .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding-bottom: 1rem;
}
.sidebar .brand .logo {
  width: 175px;
  height: auto;
  object-fit: contain;
}
.sidebar .brand .tagline {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

/* QR Share */
.qr-share {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-md);
  transition: box-shadow var(--normal) var(--ease);
}
.qr-share:hover {
  box-shadow: var(--shadow-md);
}
.qr-row {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
}
.qr-row .qr {
  width: 72px;
  height: 72px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.qr-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}
.qr-actions form {
  display: flex;
  gap: 0.4rem;
}
.qr-actions input,
.qr-actions select {
  font-size: 0.72rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  width: 100%;
}
.qr-actions input::placeholder { color: var(--ink-faint); }
.url-display {
  font-size: 0.65rem !important;
  color: var(--ink-faint) !important;
  background: transparent !important;
  border: none !important;
  padding: 0.2rem 0 !important;
  cursor: text;
}

img.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.avatar-wrap {
  display: flex;
  align-items: center;
}

/* Sidebar nav links */
.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.sidebar-links a {
  display: block;
  text-align: center;
  padding: 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: background var(--normal) var(--ease), color var(--normal) var(--ease),
    transform var(--fast) var(--ease), border-color var(--normal) var(--ease);
}
.sidebar-links a:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  transform: translateY(-1px);
}

/* Sidebar dropdown (Socials) */
.sidebar-dropdown {
  display: flex;
  flex-direction: column;
}
.dropdown-toggle {
  display: flex !important;
  align-items: center;
  justify-content: space-between !important;
}
.dropdown-caret {
  display: inline-block;
  font-size: 0.9rem;
  transition: transform var(--normal) var(--ease);
}
.dropdown-toggle.active .dropdown-caret {
  transform: rotate(180deg);
}
.dropdown-toggle.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.dropdown-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s var(--ease);
  overflow: hidden;
}
.dropdown-panel.open {
  grid-template-rows: 1fr;
}
.dropdown-panel-inner {
  overflow: hidden;
  min-height: 0;
}
.socials-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.6rem;
}
.social-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.social-field label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.social-field input {
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
}
.custom-social-row {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}
.custom-social-row input {
  flex: 1;
  min-width: 0;
}
.remove-social {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--border);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--normal) var(--ease), color var(--normal) var(--ease);
}
.remove-social:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Story tag chips (base look, shared by story-tag-section) */
.tag-list .tag {
  font-family: inherit;
  appearance: none;
}

.storage-info {
  font-size: 0.68rem;
  color: var(--ink-faint);
  margin: 0;
}

/* Shared small btn */
.btn.small {
  padding: 0.4rem 0.9rem;
  font-size: 0.75rem;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  transition: background var(--normal) var(--ease), transform var(--fast) var(--ease),
    box-shadow var(--normal) var(--ease);
}
.btn.small:hover {
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn.small:active { transform: translateY(0) scale(0.96); }

/* Generate Document */
.sidebar > .btn.full-width {
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-sm);
  transition: background var(--normal) var(--ease), transform var(--fast) var(--ease),
    box-shadow var(--normal) var(--ease);
}
.sidebar > .btn.full-width:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.sidebar > .btn.full-width:active { transform: translateY(0) scale(0.97); }

/* User footer */
.user-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.user-footer .btn.ghost {
  font-size: 0.75rem;
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  background: var(--surface);
  transition: background var(--normal) var(--ease), color var(--normal) var(--ease);
}
.user-footer .btn.ghost:hover {
  background: var(--ink);
  color: #fff;
}

/* ── Story Panel ─────────────────────────────────────── */
.story-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  overflow-y: auto;
}

/* Story editor */
.story-editor-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem 2rem;
  flex: 1;
}
.story-form h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 1rem;
}
.story-form textarea {
  width: 100%;
  background-color: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--ink);
  resize: vertical;
  outline: none;
  transition: border-color var(--normal) var(--ease), box-shadow var(--normal) var(--ease);
  box-sizing: border-box;
  font-family: inherit;
}
.story-form textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.15);
}

/* Tag sections of the story (moved below the textarea) */
.story-tag-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  margin-top: 1rem;
}
.story-tag-section h3 {
  font-size: 1rem;
  margin: 0 0 0.6rem;
}
.how-to-steps {
  margin: 0 0 0.85rem;
  padding-left: 1.2rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.tag-empty-hint {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin: 0.75rem 0 0;
}
.tag-create {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}
.tag-create label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.tag-create input {
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
}
.tag-create-actions {
  display: flex;
  gap: 0.5rem;
}
.tag-create-actions .btn {
  flex: 1;
}
.tag-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.tag-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
}
.tag-row .tag {
  flex-shrink: 0;
}
.tag-snippet {
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-row .remove-tag {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--border);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--normal) var(--ease), color var(--normal) var(--ease);
}
.tag-row .remove-tag:hover {
  background: #c1121f;
  color: #fff;
  border-color: #c1121f;
}

.story-form-footer {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}
.story-form-footer input {
  flex: 1;
  min-width: 180px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
}
.story-form-footer input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.15);
}
.story-form-footer .btn {
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: var(--radius-pill);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--normal) var(--ease), transform var(--fast) var(--ease),
    box-shadow var(--normal) var(--ease);
}
.story-form-footer .btn:hover {
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.story-form-footer .btn:active { transform: translateY(0) scale(0.97); }

/* Uploaded media */
.uploaded-media {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.75rem;
}
.uploaded-media h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.media-hint {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin: 0 0 0.9rem;
}
.media-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.4rem;
}
.media-upload-form input[type='file'] {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem;
  font-size: 0.8rem;
  border-style: dashed;
}
.media-scroll-row {
  display: flex;
  gap: 0.9rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  align-items: stretch;
  scrollbar-width: thin;
  margin-top: 1rem;
}
.media-scroll-row::-webkit-scrollbar { height: 5px; }
.media-scroll-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.media-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 130px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--normal) var(--ease), box-shadow var(--normal) var(--ease),
    transform var(--fast) var(--ease);
  flex-shrink: 0;
  padding: 0.6rem;
}
.media-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.media-card-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  color: var(--ink);
}
.media-type-icon { font-size: 1.6rem; }
.media-type {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.media-name {
  font-size: 0.62rem;
  color: var(--ink-faint);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}
.media-insert-btn {
  width: 100%;
  white-space: nowrap;
}

.media-next {
  min-width: 44px;
  align-self: stretch;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--normal) var(--ease), transform var(--fast) var(--ease);
}
.media-next:hover {
  background: var(--accent);
  transform: scale(1.05);
}
.media-next:active { transform: scale(0.95); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1100px) {
  .dashboard {
    grid-template-columns: 240px 1fr;
  }
}

@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .story-panel {
    padding: 1.25rem;
  }
  .story-editor-wrap {
    padding: 1.25rem;
  }
  .qr-row {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .story-form-footer {
    flex-direction: column;
  }
  .story-form-footer .btn {
    width: 100%;
  }
}

/* ── Settings page ────────────────────────────────────── */
.settings-page {
  max-width: 760px;
  margin: 2.5rem auto;
  padding: 0 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-header h1 {
  margin: 0.75rem 0 0.25rem;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-section-header h2 {
  font-size: 1.15rem;
  margin: 0 0 0.25rem;
}

.settings-section-header p {
  margin: 0;
  font-size: 0.88rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.field > span:first-child {
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.settings-static-value {
  margin: 0;
  padding: 0.8rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 0.9rem;
}

.settings-save-row {
  display: flex;
  justify-content: flex-end;
}

/* Toggle switch */
.switch {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  cursor: pointer;
  padding: 0.5rem 0;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 44px;
  height: 25px;
  flex-shrink: 0;
  background: var(--border);
  border-radius: var(--radius-pill);
  transition: background var(--normal) var(--ease);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 21px;
  height: 21px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--normal) var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(19px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.switch-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.switch-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
}

.switch-desc {
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* Danger zone */
.danger-zone {
  border-color: #f3c6c2;
  background: #fff6f5;
}

.btn.danger {
  background: #c1121f;
}

.btn.danger:hover {
  background: #9c0d18;
}

@media (max-width: 600px) {
  .settings-page {
    margin: 1.5rem auto;
    padding: 0 1rem 3rem;
  }
  .settings-section {
    padding: 1.25rem 1.25rem;
  }
  .settings-save-row {
    justify-content: stretch;
  }
  .settings-save-row .btn {
    width: 100%;
  }
}