:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #5b8def;
  --danger: #e85d5d;
  --ok: #3dcca8;
  font-family: system-ui, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 100%;
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.storage-line {
  flex: 1 1 280px;
  min-width: 0;
}

.link-logout {
  margin-left: auto;
  color: var(--accent);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.layout-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 1.25rem;
  align-items: start;
}

.layout-span-2 {
  grid-column: 1 / -1;
}

.layout-primary {
  grid-column: 1;
  min-width: 0;
}

.preview-aside {
  grid-column: 2;
  position: sticky;
  top: 1rem;
}

.preview-aside-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  max-height: calc(100vh - 6rem);
  overflow: auto;
}

.preview-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.preview-heading {
  margin: 0;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
}

.btn-preview-eye {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
}

.btn-preview-eye:hover:not([hidden]) {
  background: rgba(91, 141, 239, 0.15);
  border-color: var(--accent);
}

.btn-preview-eye[hidden] {
  display: none !important;
}

.preview-body {
  font-size: 0.9rem;
  line-height: 1.45;
}

.preview-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  line-height: 1.3;
}

.preview-meta {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.preview-thumb {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.preview-excerpt {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-note {
  margin: 0.75rem 0 0;
}

.preview-selected {
  background: rgba(91, 141, 239, 0.12);
}

.bulk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.bulk-toolbar select {
  min-width: 200px;
}

.bulk-count {
  margin-right: 0.25rem;
}

.btn-bulk {
  background: var(--accent);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  filter: brightness(1.12);
}

.col-check {
  width: 2.25rem;
  vertical-align: middle;
  text-align: center;
}

.preview-trigger {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.preview-trigger:hover {
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .preview-aside {
    position: static;
    grid-column: 1;
  }

  .hide-mobile {
    display: none;
  }
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.flash {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin: 0 0 1rem;
}

.flash.ok {
  background: rgba(61, 204, 168, 0.15);
  border: 1px solid var(--ok);
}

.flash.error {
  background: rgba(232, 93, 93, 0.12);
  border: 1px solid var(--danger);
}

.breadcrumb {
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .sep {
  color: var(--muted);
  margin: 0 0.25rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stack.tight {
  gap: 0.35rem;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
select {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

button {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

button:hover {
  filter: brightness(1.08);
}

.btn-danger {
  background: var(--danger);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.inline-form input[type="text"] {
  flex: 1 1 200px;
  min-width: 160px;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.upload-form input[type="file"] {
  max-width: 100%;
  font-size: 0.9rem;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table.files {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.files th,
table.files td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

table.files th {
  color: var(--muted);
  font-weight: 600;
}

.folder-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.folder-link:hover {
  text-decoration: underline;
}

.file-name {
  color: var(--text);
}

.actions {
  vertical-align: top;
  min-width: 120px;
}

.action-details summary {
  cursor: pointer;
  color: var(--accent);
  user-select: none;
}

.action-grid {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .action-grid {
    grid-template-columns: 1fr 1fr;
  }

  .danger-zone {
    grid-column: 1 / -1;
  }
}

code {
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.88em;
}

.footnote {
  margin-top: 2rem;
}

.storage-quota-modal[hidden] {
  display: none !important;
}

.storage-quota-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.storage-quota-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  cursor: pointer;
}

.storage-quota-panel {
  position: relative;
  z-index: 1;
  max-width: 420px;
  width: 100%;
  padding: 1.25rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

.storage-quota-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  color: var(--danger);
}

.storage-quota-text {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  line-height: 1.45;
}

.storage-quota-ok {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

.storage-quota-ok:hover {
  filter: brightness(1.08);
}

.read-modal[hidden] {
  display: none !important;
}

.read-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

.read-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  cursor: pointer;
}

.read-modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(100vw, 1200px);
  height: 100vh;
  max-height: 100dvh;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

.read-modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.read-modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.read-modal-close {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--border);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.read-modal-close:hover {
  filter: brightness(1.15);
}

.read-modal-iframe {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: none;
  background: #2a2a2a;
}

@media (max-width: 640px) {
  .read-modal-panel {
    width: 100vw;
  }
}
