@import "actiontext.css";

:root {
  --ink: #1c2430;
  --ink-soft: #2a3444;
  --cream: #f3eee6;
  --paper: #fffdf9;
  --line: #e3d9cb;
  --terracotta: #c4654a;
  --terracotta-deep: #9d4a33;
  --moss: #3f6d59;
  --shadow: 0 18px 40px rgba(28, 36, 48, 0.08);
  --font: "Outfit", sans-serif;
  --serif: "Fraunces", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 380;
}

h1, h2, .brand, .auth-card h1, .public-title {
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -0.03em;
}

a { color: inherit; }

.btn-accent {
  --bs-btn-bg: var(--terracotta);
  --bs-btn-border-color: var(--terracotta);
  --bs-btn-hover-bg: var(--terracotta-deep);
  --bs-btn-hover-border-color: var(--terracotta-deep);
  --bs-btn-color: #fffdf9;
  --bs-btn-hover-color: #fffdf9;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.35rem;
}

.brand-mark {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border-radius: 0.7rem;
  background: var(--terracotta);
  color: white;
  font-family: var(--serif);
}

.flash-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1080;
  width: min(24rem, calc(100vw - 2rem));
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar, .app-offcanvas {
  background: var(--ink);
  color: #f6f1ea;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-brand, .sidebar-user, .sidebar-nav { padding: 1.25rem; }
.sidebar-brand { display: flex; gap: 0.8rem; align-items: center; }
.sidebar-brand small { display: block; color: #c9bfb2; }
.sidebar-nav { flex: 1; overflow: auto; }
.sidebar-user { border-top: 1px solid rgba(255, 255, 255, 0.08); }

.nav-folder, .folder-tree a {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  padding: 0.45rem 0.6rem;
  border-radius: 0.7rem;
  color: #efe8df;
  text-decoration: none;
}

.nav-folder.is-current, .folder-tree a.is-current, .nav-folder:hover, .folder-tree a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.folder-tree, .folder-tree ul { list-style: none; margin: 0.2rem 0 0; padding-left: 0.8rem; }
.folder-tree { padding-left: 0; }

.user-chip {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.8rem;
  color: #ddd4c8;
  font-size: 0.92rem;
  word-break: break-all;
}

.app-main { min-width: 0; padding: 1.5rem 1.6rem 2.5rem; }

.library-bar, .library-actions, .viewer-head, .viewer-actions, .share-row, .share-row-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.library-bar, .viewer-head { justify-content: space-between; }
.library-heading { display: flex; gap: 0.8rem; align-items: center; min-width: 0; }
.library-heading h1, .public-title { margin: 0.15rem 0 0; font-size: clamp(1.8rem, 3vw, 2.6rem); }
.title-line { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.title-line h1, .title-line h2 { min-width: 0; }
.library-actions, .share-row-actions { flex-wrap: wrap; justify-content: flex-end; }

.crumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; color: #74695d; font-size: 0.92rem; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--terracotta-deep); }

.library-collapse { margin: 1rem 0; }
.folder-form { display: flex; gap: 0.6rem; max-width: 36rem; }

.workspace { display: grid; gap: 1.2rem; margin-top: 1.2rem; }
.workspace.has-viewer { grid-template-columns: minmax(0, 1fr) minmax(280px, 400px); align-items: start; }

.library-board {
  min-height: 60vh;
  border-radius: 1.4rem;
  padding: 0.4rem;
}
.library-board.is-dragging { outline: 2px dashed var(--terracotta); background: rgba(196, 101, 74, 0.06); }

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.9rem;
}

.item-card, .public-card, .viewer, .auth-card, .modal-content {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.item-card, .public-card {
  position: relative;
  border-radius: 1.1rem;
  min-height: 9.5rem;
  padding: 1rem;
}

.item-card.is-active { outline: 2px solid var(--terracotta); }
.item-card-main, .public-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-decoration: none;
  color: inherit;
}
.item-actions { position: absolute; top: 0.55rem; right: 0.55rem; display: flex; gap: 0.25rem; }
.item-title { font-weight: 640; line-height: 1.25; padding-right: 4.6rem; word-break: break-word; }
.item-meta, .eyebrow, .auth-lead, .public-lead, .share-hint { color: #74695d; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; margin-bottom: 0; }

.item-icon {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 0.8rem;
  background: #f3e6df;
  color: var(--terracotta-deep);
  font-size: 1.2rem;
}
.item-icon.audio { background: #efe4d4; color: #8a5a2a; }
.item-icon.video { background: #e5ebe4; color: var(--moss); }
.item-icon.image { background: #e7e4f1; color: #53457a; }
.item-icon.document, .item-icon.folder { background: #f3e6df; }

.icon-btn {
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: rgba(28, 36, 48, 0.06);
  color: var(--ink);
  display: grid;
  place-items: center;
}
.sidebar .icon-btn, .app-offcanvas .icon-btn { background: rgba(255,255,255,0.08); color: white; }

.viewer, .open-player, .protected-stage, .doc-poster, .audio-poster {
  border-radius: 1.2rem;
}
.viewer { padding: 1rem; position: sticky; top: 1rem; }
.viewer h2 { font-size: 1.45rem; margin: 0; word-break: break-word; }
.viewer-actions { margin-top: 0.9rem; }

.open-player video, .open-player img, .open-player iframe, .protected-media, .stage-surface canvas {
  width: 100%;
  border-radius: 0.9rem;
  background: #11161d;
}
.open-player video, .protected-media { max-height: 62vh; }
.open-player iframe { height: 68vh; border: 0; }
.open-player img { height: auto; background: transparent; }
.open-player .btn { margin-top: 0.8rem; }

.audio-poster, .doc-poster, .empty-state {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  text-align: center;
  padding: 2rem 1rem;
}
.audio-poster, .doc-poster { background: #f7f1e8; }
.audio-poster i, .doc-poster i, .empty-state i { font-size: 2rem; color: var(--terracotta); }
.empty-state {
  margin: 3rem auto;
  max-width: 28rem;
}
.empty-state h2 { font-family: var(--serif); }

.upload-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.upload-list li {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}
.upload-list i {
  display: block;
  height: 0.35rem;
  width: 0;
  border-radius: 99px;
  background: var(--terracotta);
}
.upload-list .is-error { color: #8d2f2f; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at top left, rgba(196, 101, 74, 0.18), transparent 28rem),
    var(--cream);
}
.auth-card { width: min(28rem, 100%); border-radius: 1.5rem; padding: 2rem; }
.auth-card h1 { margin: 1rem 0 0.4rem; }
.auth-form { display: grid; gap: 0.45rem; margin-top: 1.2rem; }
.auth-form .btn { margin-top: 0.6rem; }
.auth-links { display: flex; gap: 0.5rem; justify-content: center; margin: 1rem 0 0; }
.auth-links a { color: var(--terracotta-deep); }

.public-body { background: var(--cream); }
.public-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.4rem;
}
.public-main { width: min(1040px, calc(100% - 2rem)); margin: 0 auto 3rem; }
.public-lead { max-width: 40rem; }
.back-link { display: inline-flex; gap: 0.4rem; margin-bottom: 0.8rem; color: var(--terracotta-deep); text-decoration: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  background: #e7f0ea;
  color: var(--moss);
  font-size: 0.82rem;
}
.pill-locked { background: #f8e7e1; color: var(--terracotta-deep); }

.share-create { display: grid; gap: 0.7rem; margin-bottom: 1.2rem; }
.share-country { display: flex; gap: 0.45rem; align-items: center; margin-top: 0.7rem; }
.share-country .form-select { max-width: 16rem; }
.share-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.8rem; }
.share-row {
  justify-content: space-between;
  align-items: flex-start;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}
.share-row code {
  display: block;
  word-break: break-all;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}
.share-empty { color: #74695d; }

.protected-stage { user-select: none; }
.stage-frame { position: relative; overflow: hidden; border-radius: 1rem; background: #141a21; min-height: 16rem; }
.stage-surface { position: relative; z-index: 1; }
.protected-media.is-standby {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.stage-surface canvas { display: block; margin: 0 auto 0.6rem; background: white; }
.stage-shield { position: absolute; inset: 0; z-index: 3; background: transparent; }
.protected-stage.is-audio .stage-frame { background: transparent; min-height: 0; }
.protected-stage.is-audio .stage-shield { display: none; }
.protected-stage.is-audio .protected-media {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.stage-status { margin: 0.8rem 0; color: #74695d; }
.stage-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.8rem;
}
.stage-controls input[type="range"] { accent-color: var(--terracotta); }
.stage-track {
  position: relative;
  flex: 1 1 18rem;
  min-width: 12rem;
  height: 1.4rem;
  display: flex;
  align-items: center;
}
.stage-rail {
  position: absolute;
  left: 0;
  right: 0;
  height: 0.35rem;
  border-radius: 999px;
  background: #e4ddd4;
  overflow: hidden;
  pointer-events: none;
}
.stage-buffer, .stage-played {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
}
.stage-buffer { background: #d7b2a6; }
.stage-played { background: var(--terracotta); }
.stage-controls .stage-seek {
  width: 100%;
  position: relative;
  z-index: 1;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  height: 1.4rem;
  margin: 0;
}
.stage-seek::-webkit-slider-runnable-track {
  height: 0.35rem;
  background: transparent;
}
.stage-seek::-moz-range-track {
  height: 0.35rem;
  background: transparent;
  border: 0;
}
.stage-seek::-moz-range-progress {
  background: transparent;
}
.stage-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 0.95rem;
  height: 0.95rem;
  margin-top: -0.3rem;
  border-radius: 50%;
  background: var(--terracotta);
  border: 0;
}
.stage-seek::-moz-range-thumb {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--terracotta);
  border: 0;
}
.stage-volume-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}
.stage-speaker {
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1;
  display: inline-grid;
  place-items: center;
}
.stage-controls .stage-volume { flex: 0 0 4.5rem; width: 4.5rem; margin: 0; }
.stage-btn, .dropdown-menu .dropdown-item {
  border: 0;
  background: transparent;
}
.stage-btn {
  border-radius: 999px;
  background: var(--ink);
  color: white;
  padding: 0.4rem 0.85rem;
}
.stage-play {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 1.15rem;
  line-height: 1;
}
.stage-time { font-variant-numeric: tabular-nums; color: #5e564c; }

.description-form { display: grid; gap: 0.45rem; margin-top: 1rem; }
.description-form .btn { justify-self: start; }
.field-hint { margin: 0; color: #74695d; font-size: 0.92rem; }
.folder-presentation { margin: 0.4rem 0 1.2rem; max-width: 46rem; }
.folder-banner {
  display: block;
  width: 100%;
  height: clamp(9rem, 28vw, 18rem);
  object-fit: cover;
  object-position: center;
  border-radius: 1rem;
  margin: 0 0 1.2rem;
  background: #141a21;
}
.folder-presentation .form-check { display: flex; align-items: center; gap: 0.45rem; margin: 0.2rem 0; }
trix-editor {
  min-height: 8rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  font-family: var(--font);
}
trix-toolbar .trix-button-row { flex-wrap: wrap; gap: 0.35rem; }
trix-toolbar .trix-button-group { margin-bottom: 0; }
.file-description {
  margin-top: 1.4rem;
  padding: 1.1rem 1.2rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1rem;
}
.file-description .trix-content { line-height: 1.6; }
.file-description .trix-content > :first-child { margin-top: 0; }
.file-description .trix-content > :last-child { margin-bottom: 0; }
.file-description img,
.description-form .attachment img,
trix-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.7rem;
}
.file-description .attachment__caption { display: none; }
.dropdown-menu form { margin: 0; }
.dropdown-menu form .dropdown-item { width: 100%; text-align: left; }

.print-guard { display: none; }
@media print {
  .protected-stage { display: none !important; }
  .print-guard { display: block !important; }
}

@media (max-width: 991.98px) {
  .app-shell { grid-template-columns: 1fr; }
  .workspace.has-viewer { grid-template-columns: 1fr; }
  .viewer { position: static; }
  .library-bar, .folder-form, .share-row { align-items: stretch; flex-direction: column; }
  .library-actions, .share-row-actions { justify-content: flex-start; }
  .app-offcanvas { min-height: 100%; }
}
