:root {
  --bg0: #e8eef2;
  --bg1: #f4f7f9;
  --ink: #1a2332;
  --muted: #5c6b7a;
  --line: #c9d4de;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --accent: #0d7377;
  --accent-hover: #095c5f;
  --accent-soft: #d7eaea;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(26, 35, 50, 0.08);
  --radius: 14px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg1);
  line-height: 1.45;
  padding: 1.25rem 1.25rem 3rem;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(13, 115, 119, 0.16), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(47, 90, 140, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 42%, #eef2f5);
}

.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(26, 35, 50, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 35, 50, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 75%);
}

.topbar {
  max-width: 1200px;
  margin: 0 auto 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.brand-logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.72rem;
  flex-shrink: 0;
  display: block;
  box-shadow:
    0 1px 2px rgba(255, 255, 255, 0.9),
    0 6px 16px rgba(26, 35, 50, 0.08),
    0 0 0 1px rgba(201, 212, 222, 0.55);
}

.brand-logo--lg {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1rem;
  margin: 0 auto 0.85rem;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.4rem 0.3rem 0.35rem;
  backdrop-filter: blur(8px);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.layout-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  min-width: 0;
}

.panel--entry {
  padding-top: 0.85rem;
}

.mode-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  margin-bottom: 0.85rem;
  background: #e8eef2;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.mode-tab {
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 0.45rem 0.95rem;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
}

.mode-tab:hover {
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
}

.mode-tab.is-active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(26, 35, 50, 0.08);
}

.mode-pane .hint {
  margin: 0 0 0.65rem;
}

.panel--recent {
  min-height: 32rem;
}

.panel-head {
  margin-bottom: 0.85rem;
}

.panel-head--row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.panel-actions .btn {
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.25rem 0 0;
}

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

.field-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input,
.input-file,
input[type=text],
input[type=file] {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: var(--surface-solid);
  color: var(--ink);
}

.input:focus,
input[type=text]:focus {
  outline: 2px solid rgba(13, 115, 119, 0.25);
  border-color: var(--accent);
}

.btn,
button {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  background: #f7fafb;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:hover,
button:hover {
  background: #eef3f6;
}

.btn:active,
button:active {
  transform: translateY(1px);
}

.btn:disabled,
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
}

.btn-block {
  width: 100%;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

code {
  font-family: var(--mono);
  background: var(--accent-soft);
  color: #0a5558;
  padding: 0.05rem 0.3rem;
  border-radius: 5px;
  font-size: 0.86em;
}

.recent-list {
  min-height: 26rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  letter-spacing: -0.011em;
  color: var(--ink);
}

.recent-tree {
  border: 1px solid #d7e1e8;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.recent-folder-row {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  width: 100%;
  min-height: 2.4rem;
  padding: 0.32rem 0.8rem 0.32rem calc(0.7rem + var(--depth, 0) * 1.05rem);
  border: none;
  border-bottom: 1px solid #e6eef3;
  border-radius: 0;
  background: #f5f8fa;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.014em;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.recent-folder-row:hover {
  background: #eaf3f4;
}

.recent-folder-row:active {
  transform: none;
}

.recent-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 0.65rem;
  width: 100%;
  flex-shrink: 0;
  min-height: 2.35rem;
  padding: 0.34rem 0.85rem 0.34rem calc(1.15rem + var(--depth, 0) * 1.05rem);
  border: none;
  border-bottom: 1px solid #f1f5f8;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.011em;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
}

.recent-files > .recent-file:last-child,
.recent-folder.is-collapsed:last-child > .recent-folder-row {
  border-bottom-color: transparent;
}

.recent-folder-children > .recent-files-frame.is-scroll:last-child,
.recent-tree > .recent-files-frame.is-scroll:last-child {
  border-bottom-color: transparent;
}

.recent-file:hover {
  background: #f3fafa;
  text-decoration: none;
  box-shadow: inset 2px 0 0 var(--accent);
}

.recent-file:focus-visible,
.recent-folder-row:focus-visible {
  outline: 2px solid rgba(13, 115, 119, 0.35);
  outline-offset: -2px;
}

.recent-chevron {
  flex-shrink: 0;
  width: 0.42rem;
  height: 0.42rem;
  margin-top: -0.12rem;
  margin-right: 0.12rem;
  border-right: 1.75px solid #607280;
  border-bottom: 1.75px solid #607280;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.recent-folder.is-collapsed > .recent-folder-row .recent-chevron {
  transform: rotate(-45deg);
  margin-top: 0;
}

.recent-folder.is-collapsed > .recent-folder-children {
  display: none;
}

.recent-folder-name {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.28rem;
  overflow: hidden;
  font-family: var(--sans);
  white-space: nowrap;
}

.recent-folder-prefix {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #7d8c99;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0;
}

.recent-folder-leaf {
  flex: 0 1 auto;
  min-width: 3.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 650;
  font-size: 0.9rem;
  letter-spacing: -0.015em;
}

.recent-folder-count {
  flex-shrink: 0;
  min-width: 1.35rem;
  padding: 0.06rem 0.42rem;
  border-radius: 999px;
  background: #e6eef3;
  color: #4c6270;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1.35;
  text-align: center;
}

.recent-files-frame {
  position: relative;
  background: #fff;
}

.recent-files-frame.is-scroll {
  border-bottom: 1px solid #e6eef3;
}

.recent-files {
  display: flex;
  flex-direction: column;
  background: #fff;
}

.recent-files.is-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c3d0da transparent;
  max-height: 14.5rem;
}

.recent-files.is-scroll::-webkit-scrollbar {
  width: 8px;
}

.recent-files.is-scroll::-webkit-scrollbar-thumb {
  background: #c3d0da;
  border: 2px solid #fff;
  border-radius: 99px;
}

.recent-files-fade {
  position: absolute;
  left: 0;
  right: 0.55rem;
  bottom: 0;
  height: 1.15rem;
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.96));
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.recent-files-frame.is-at-end .recent-files-fade {
  opacity: 0;
}

.recent-file-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.06rem;
}

.recent-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: -0.012em;
}

.recent-badge {
  flex-shrink: 0;
  align-self: center;
  font-family: var(--sans);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.36rem;
  border-radius: 999px;
  line-height: 1.25;
}

.recent-badge--pfs {
  background: #e7eef3;
  color: #3e5160;
}

.recent-badge--oss {
  background: var(--accent-soft);
  color: #0a5558;
}

.recent-meta {
  flex-shrink: 0;
  align-self: center;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  color: #7d8c99;
  letter-spacing: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.recent-note {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #5d6e7c;
  font-size: 0.75rem;
  font-weight: 450;
  letter-spacing: 0;
  line-height: 1.35;
}

.recent-note-count {
  color: var(--accent);
  font-weight: 650;
  margin-right: 0.3rem;
}

.recent-empty,
.recent-loading,
.recent-error {
  padding: 2.5rem 0.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.recent-error { color: var(--danger); }

.recent-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.pager-info {
  font-size: 0.85rem;
  color: var(--muted);
}

.breadcrumb {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.65rem;
  word-break: break-all;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-solid);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid #e7edf2;
}

th {
  background: #f3f7f9;
  font-weight: 600;
}

tr:last-child td { border-bottom: none; }

.versions-row td {
  background: #f7fafb;
  padding: 0.6rem 0.9rem;
}

.versions-row table {
  font-size: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

a:hover { text-decoration: underline; }

.browse-user-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.browse-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.browse-user-link {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.browse-user-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.browse-user-avatar--placeholder {
  display: inline-block;
  background: #d0d7de;
}

tr.here-row td { background: #eef8f4; }

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 28, 38, 0.48);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.auth-overlay.is-open { display: flex; }

.auth-modal {
  background: var(--surface-solid);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  max-width: 380px;
  width: calc(100% - 2rem);
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.auth-modal h2 { margin: 0 0 0.35rem; }

.auth-error {
  color: var(--danger);
  font-size: 0.88rem;
  margin: 0.75rem 0;
}

#toast {
  position: fixed;
  bottom: 1.1rem;
  right: 1.1rem;
  background: var(--ink);
  color: white;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  max-width: 400px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 1100;
}

#toast.err { background: var(--danger); }

@media (max-width: 960px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .field-row {
    flex-wrap: wrap;
  }

  .field-row .btn,
  .field-row button {
    flex: 1 1 auto;
  }

  .panel--recent {
    min-height: 0;
  }

  .recent-list {
    min-height: 16rem;
  }

  .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .mode-tabs {
    display: flex;
    width: 100%;
  }

  .mode-tab {
    flex: 1;
    text-align: center;
  }
}
