@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Sora:wght@500;600;700&display=swap');

:root {
  --bg0: #0e1518;
  --bg1: #152025;
  --bg2: #1c2a31;
  --panel: rgba(22, 34, 40, 0.88);
  --panel-solid: #162228;
  --line: rgba(140, 180, 170, 0.16);
  --text: #e8f1ee;
  --muted: #8fa4a0;
  --accent: #3db89a;
  --accent-2: #f0b429;
  --danger: #e85d5d;
  --ok: #45c49a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --font: 'Manrope', sans-serif;
  --display: 'Sora', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 184, 154, 0.18), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(240, 180, 41, 0.12), transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 45%, #10191d);
  min-height: 100%;
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(10, 16, 18, 0.55);
  backdrop-filter: blur(14px);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(61, 184, 154, 0.95), rgba(240, 180, 41, 0.75));
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  color: #0d1417;
  box-shadow: 0 10px 30px rgba(61, 184, 154, 0.25);
  animation: brandIn 700ms ease both;
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 2px;
  line-height: 1.35;
  max-width: 16rem;
}

.auth-card .brand h1 { font-size: 1.35rem; }
.auth-card .brand small { max-width: 22rem; font-size: 0.85rem; }

.nav-group { display: flex; flex-direction: column; gap: 6px; }
.nav-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: 180ms ease;
}
.nav-btn:hover, .nav-btn.active {
  background: rgba(61, 184, 154, 0.12);
  color: var(--text);
}
.nav-btn.active { box-shadow: inset 0 0 0 1px rgba(61, 184, 154, 0.25); }

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
}

.main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 21, 24, 0.45);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.search {
  flex: 1;
  min-width: 0;
  position: relative;
}
.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 12px 18px 12px 42px;
  outline: none;
}
.search input:focus { border-color: rgba(61, 184, 154, 0.45); }
.search::before {
  content: '⌕';
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.view-toggle {
  display: inline-flex;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.view-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
}
.view-toggle button.active {
  background: rgba(61, 184, 154, 0.18);
  color: var(--text);
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  transition: 160ms ease;
  white-space: nowrap;
}
.btn:hover { border-color: rgba(61, 184, 154, 0.4); }
.btn-primary {
  background: linear-gradient(135deg, #3db89a, #2a9a7f);
  border: 0;
  color: #06110e;
  font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { color: #ffd1d1; border-color: rgba(232, 93, 93, 0.35); }
.btn-ghost { background: transparent; }

.content-area {
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}
.content-area.full-workspace {
  grid-template-columns: 1fr;
}

.workspace {
  padding: 20px 24px 40px;
  min-width: 0;
  overflow: auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}
.breadcrumb button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
}
.breadcrumb button:hover { color: var(--accent); }
.breadcrumb .sep { opacity: 0.45; }

.dropzone {
  border: 1.5px dashed rgba(61, 184, 154, 0.35);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  text-align: center;
  color: var(--muted);
  background: rgba(61, 184, 154, 0.04);
  transition: 180ms ease;
}
.dropzone.active {
  border-color: var(--accent);
  background: rgba(61, 184, 154, 0.1);
  color: var(--text);
  transform: translateY(-1px);
}

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

.file-card {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 18px;
  padding: 14px;
  cursor: pointer;
  transition: 180ms ease;
  animation: rise 420ms ease both;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.file-card:hover {
  transform: translateY(-3px);
  border-color: rgba(61, 184, 154, 0.4);
  box-shadow: var(--shadow);
}
.file-card.selected {
  border-color: rgba(61, 184, 154, 0.7);
  box-shadow: 0 0 0 1px rgba(61, 184, 154, 0.35);
}

.thumb {
  height: 88px;
  border-radius: 12px;
  background: linear-gradient(160deg, #203038, #172228);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.thumb img, .thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb .icon { font-size: 2rem; opacity: 0.9; }
.file-share-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  border: 0;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: .78rem;
  background: rgba(14, 21, 24, 0.88);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.file-share-btn:hover { background: var(--accent); color: #0d1417; }
.file-list .file-share-btn { position: static; }
.file-card h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta {
  color: var(--muted);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.file-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}
.file-list table {
  width: 100%;
  border-collapse: collapse;
}
.file-list th, .file-list td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.file-list th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(0,0,0,0.18);
}
.file-list tr { cursor: pointer; transition: 120ms ease; }
.file-list tr:hover { background: rgba(61, 184, 154, 0.06); }
.file-list tr.selected { background: rgba(61, 184, 154, 0.12); }

.inspector {
  border-left: 1px solid var(--line);
  background: rgba(12, 18, 21, 0.55);
  backdrop-filter: blur(12px);
  padding: 20px;
  overflow: auto;
}

.inspector h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.1rem;
}
.inspector .muted { color: var(--muted); font-size: 0.88rem; }
.preview-box {
  margin: 16px 0;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #10171b;
  min-height: 180px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.preview-box img, .preview-box video, .preview-box iframe {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 0;
}
.field { margin: 14px 0; }
.field label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
.field textarea { min-height: 90px; resize: vertical; }
.attr-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(61, 184, 154, 0.12);
  color: #b7ebe0;
  font-size: 0.78rem;
  margin: 2px 4px 2px 0;
}

.panel-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty strong {
  display: block;
  color: var(--text);
  font-family: var(--display);
  font-size: 1.2rem;
  margin-bottom: 8px;
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-page::before {
  content: '';
  position: absolute;
  inset: -20% 40% auto -10%;
  height: 60%;
  background: radial-gradient(circle, rgba(61, 184, 154, 0.22), transparent 70%);
  animation: drift 12s ease-in-out infinite alternate;
}
.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
  position: relative;
  animation: rise 500ms ease both;
}
.auth-card .brand { margin-bottom: 24px; }
.auth-card h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.6rem;
}
.auth-card p { color: var(--muted); margin: 0 0 22px; }
.auth-actions { display: flex; gap: 10px; margin-top: 18px; }
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.tabs button {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 10px;
}
.tabs button.active {
  background: rgba(61, 184, 154, 0.14);
  color: var(--text);
  border-color: rgba(61, 184, 154, 0.35);
}

.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #173029;
  border: 1px solid rgba(61, 184, 154, 0.35);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  min-width: 220px;
  box-shadow: var(--shadow);
  animation: rise 250ms ease both;
}
.toast.error { background: #2a1717; border-color: rgba(232, 93, 93, 0.4); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
  animation: fade 180ms ease both;
}
.modal {
  width: min(480px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 8px; font-family: var(--display); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.users-table, .shares-table {
  width: 100%;
  border-collapse: collapse;
}
.users-table th, .users-table td,
.shares-table th, .shares-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.9rem;
}

.hidden { display: none !important; }
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(240, 180, 41, 0.15);
  color: #f6d98a;
}
.badge.ok { background: rgba(61, 184, 154, 0.15); color: #9fe4d1; }
.badge.danger { background: rgba(232, 93, 93, 0.15); color: #ffb4b4; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes brandIn {
  from { opacity: 0; transform: scale(0.85) rotate(-8deg); }
  to { opacity: 1; transform: none; }
}
@keyframes drift {
  from { transform: translate3d(0,0,0); }
  to { transform: translate3d(40px, 20px, 0); }
}

@media (max-width: 1100px) {
  .content-area { grid-template-columns: 1fr; }
  .inspector {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 14px;
  }
  .nav-group { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; width: 100%; }
}

/* Topics */
.topic-composer textarea { min-height: 110px; }
.topic-file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.topic-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
  animation: rise 400ms ease both;
}
.topic-card h3 { margin: 0 0 4px; font-family: var(--display); font-size: 1.05rem; }
.topic-body { margin: 12px 0; line-height: 1.55; color: #d5e4df; }
.topic-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.topic-thumb {
  border: 0;
  padding: 0;
  width: 96px;
  height: 96px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #10171b;
}
.topic-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 220ms ease; }
.topic-thumb:hover img { transform: scale(1.06); }
.topic-file-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.topic-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* Photos — Google Photos style grid */
.photo-masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  align-content: start;
}
.photo-day {
  grid-column: 1 / -1;
  font-family: var(--display);
  font-size: .92rem;
  font-weight: 600;
  margin: 12px 2px 4px;
  color: var(--text);
}
.photo-tile {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  margin: 0;
  border: 0;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #10171b;
}
.photo-tile img,
.photo-ph {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-tile img {
  opacity: .35;
  transition: opacity 200ms ease, transform 280ms ease, filter 280ms ease;
}
.photo-tile img.photo-loaded { opacity: 1; }
.photo-ph {
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  color: var(--muted);
}
.photo-pending { opacity: .75; }
.photo-tile:hover img { transform: scale(1.04); filter: brightness(1.06); }
.photo-meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 18px 8px 6px;
  font-size: .68rem;
  color: #e8f0f3;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 180ms ease;
}
.photo-tile:hover .photo-meta { opacity: 1; }
.photos-sentinel {
  grid-column: 1 / -1;
  text-align: center;
  padding: 16px;
  font-size: .85rem;
}
.photo-skel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}
.photo-skel-tile {
  aspect-ratio: 1;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.09), rgba(255,255,255,.04));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Drive */
.drive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.drive-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: 12px;
  cursor: pointer;
  transition: 160ms ease;
  animation: rise 360ms ease both;
}
.drive-card:hover {
  transform: translateY(-2px);
  border-color: rgba(61, 184, 154, 0.4);
}
.drive-thumb {
  height: 100px;
  border-radius: 12px;
  background: linear-gradient(160deg, #203038, #172228);
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 10px;
}
.drive-thumb img { width: 100%; height: 100%; object-fit: cover; }
.drive-icon { font-size: 2rem; }
.drive-card h4 {
  margin: 0;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Viewer modal */
.viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(6, 10, 12, 0.92);
  backdrop-filter: blur(8px);
  display: grid;
  grid-template-rows: auto 1fr;
  animation: fade 180ms ease both;
}
.viewer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 21, 24, 0.9);
}
.viewer-title {
  font-family: var(--display);
  font-weight: 600;
  max-width: 40vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-page { color: var(--muted); font-size: 0.9rem; }
.viewer-stage {
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 20px;
}
.viewer-media {
  max-width: min(96vw, 1200px);
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.viewer-frame {
  width: min(96vw, 1000px);
  height: calc(100vh - 140px);
  border: 0;
  border-radius: 8px;
  background: #fff;
}
.pdf-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--muted);
}
.pdf-canvas {
  background: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow);
  max-width: 100%;
}
.docx-book {
  width: min(900px, 96vw);
  background: #f7f4ef;
  color: #1a1a1a;
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 140px);
  overflow: auto;
}
.docx-book .docx-wrapper { background: transparent !important; }
.viewer-loading { color: var(--muted); }
.viewer-audio { text-align: center; color: var(--text); }

/* Document editor */
.doc-editor-host {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(6, 10, 12, 0.88);
  display: grid;
  place-items: stretch;
  padding: 16px;
}
.doc-editor-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  min-height: 0;
}
.doc-editor-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.doc-editor-body {
  min-height: 0;
  overflow: hidden;
  padding: 12px;
}
.doc-textarea {
  width: 100%;
  height: calc(100vh - 140px);
  resize: none;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.45;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #0c1215;
  color: var(--text);
}
.doc-version-panel {
  width: min(320px, 40vw);
  border-left: 1px solid var(--line);
  padding: 12px;
  overflow: auto;
  background: rgba(0,0,0,0.15);
}
.doc-version-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.version-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.version-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.panel-card + .panel-card { margin-top: 16px; }
.panel-card h3 { font-family: var(--display); }
