:root {
  --paper: #f6f2e9;
  --surface: #fffdf8;
  --surface-strong: #29251f;
  --line: #d7cebf;
  --line-dark: #50493e;
  --text: #211d18;
  --muted: #665d50;
  --accent: #0f766e;
  --accent-dark: #0a4f49;
  --warn: #9f3a22;
  --shadow: 0 16px 38px rgba(42, 35, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Aptos", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(41, 37, 31, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(41, 37, 31, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  white-space: nowrap;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 520px);
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--surface-strong);
  padding-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

h3 {
  margin-bottom: 4px;
  font-size: 16px;
}

.server-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--text);
  background: #fffefa;
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus,
.btn:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.24);
  outline-offset: 2px;
}

.btn {
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #f4eadb;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 41px;
  padding: 9px 14px;
  font-weight: 800;
  text-decoration: none;
}

.btn:hover {
  background: #eadcc8;
}

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

.btn.primary:hover {
  background: var(--accent-dark);
}

.btn.danger {
  color: var(--warn);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.btn.block {
  width: 100%;
}

.auth-panel,
.panel,
.library {
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.2fr);
  gap: 18px;
  padding: 18px;
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.button-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  grid-column: 1 / -1;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.side {
  display: grid;
  gap: 12px;
}

.account-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--surface-strong);
  border-radius: 8px;
  background: var(--surface-strong);
  color: #fffaf0;
  padding: 10px;
}

.account-strip span {
  color: #cbbfac;
  font-size: 12px;
  font-weight: 800;
}

.account-strip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel,
.library {
  padding: 14px;
}

.panel {
  display: grid;
  gap: 12px;
}

.library-head {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 0;
}

.status {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: #fbf7ef;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.status.slim {
  min-height: 34px;
  padding: 7px 10px;
  margin-bottom: 12px;
}

.status.error {
  border-left-color: var(--warn);
  background: #fff1eb;
  color: var(--warn);
}

.file-list {
  display: grid;
  gap: 10px;
}

.file-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  padding: 12px;
}

.file-icon {
  width: 58px;
  height: 58px;
  border: 1px solid var(--surface-strong);
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #eadcc8;
  font-size: 12px;
  font-weight: 900;
}

.file-main {
  min-width: 0;
}

.file-main h3,
.file-main p {
  overflow-wrap: anywhere;
}

.file-main p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 9px;
}

dl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0;
}

dl div {
  min-width: 88px;
}

dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

dd {
  margin: 0;
  font-size: 13px;
}

.file-actions {
  display: flex;
  gap: 8px;
}

.empty {
  border: 1px dashed var(--line-dark);
  border-radius: 8px;
  color: var(--muted);
  margin: 0;
  padding: 18px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .topbar,
  .workspace,
  .auth-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  h1 {
    font-size: 28px;
  }

  .server-line,
  .auth-grid,
  .file-row {
    grid-template-columns: 1fr;
  }

  .file-actions,
  .button-pair {
    grid-template-columns: 1fr;
    display: grid;
  }
}
