:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #607080;
  --line: #dce3ea;
  --primary: #0f766e;
  --primary-strong: #0a5f59;
  --secondary: #245b8f;
  --soft: #edf6f4;
  --danger: #b42318;
  --shadow: 0 18px 56px rgba(22, 34, 51, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
}

.brand {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav form {
  margin: 0;
}

.nav a,
.link-button,
.nav-primary {
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}

.nav-primary {
  color: var(--primary);
  font-weight: 700;
}

main {
  padding: clamp(18px, 4vw, 44px);
}

.home-shell {
  min-height: calc(100vh - 136px);
  display: grid;
  align-content: center;
  gap: 22px;
}

.auth-shell {
  min-height: calc(100vh - 136px);
  display: grid;
  align-items: center;
}

.home-title {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.home-title h1 {
  font-size: clamp(34px, 7vw, 68px);
  letter-spacing: 0;
  margin-bottom: 10px;
}

.home-title p {
  color: var(--muted);
  font-size: 18px;
  margin-bottom: 0;
}

.home-grid {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 26px);
}

.panel-head,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

h1 {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.05;
  margin-bottom: 8px;
}

h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.panel-head span,
.section-head p,
.muted,
.file-row p,
.file-summary p {
  color: var(--muted);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dropzone {
  min-height: 190px;
  border: 2px dashed #9fb2c5;
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  cursor: pointer;
  background: #fbfdff;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.is-dragging,
.upload-form.is-dragging .dropzone {
  border-color: var(--primary);
  background: #eefaf8;
}

.dropzone.inline {
  min-height: 92px;
}

.drop-title {
  width: 100%;
  padding: 0 18px;
  font-size: 25px;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

.drop-meta {
  color: var(--muted);
  padding: 0 18px;
  text-align: center;
  overflow-wrap: anywhere;
}

.primary,
.secondary,
.danger {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

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

.primary:hover {
  background: var(--primary-strong);
}

.secondary {
  color: var(--secondary);
  background: #e9f2fb;
}

.danger {
  color: #fff;
  background: var(--danger);
}

.wide {
  width: 100%;
}

.small {
  min-height: 34px;
  padding: 0 12px;
}

.upload-form {
  display: grid;
  gap: 14px;
}

.dashboard-upload {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.dashboard-upload .progress,
.dashboard-upload .upload-result,
.dashboard-upload .settings-grid {
  grid-column: 1 / -1;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

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

.settings-grid input,
.settings-grid select {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.code-form {
  display: grid;
  gap: 14px;
}

.code-input {
  width: 100%;
  height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  text-align: center;
  font-size: clamp(36px, 10vw, 60px);
  font-weight: 900;
  letter-spacing: 0;
}

.compact-actions {
  margin-top: 14px;
}

.progress {
  height: 10px;
  overflow: hidden;
  background: #e7edf3;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--primary);
}

.upload-result {
  min-height: 24px;
  display: grid;
  gap: 12px;
  color: var(--primary);
  font-weight: 800;
}

.upload-done {
  display: grid;
  gap: 12px;
  color: var(--text);
  font-weight: 400;
}

.upload-status {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--primary);
  font-weight: 800;
}

.upload-status span {
  overflow-wrap: anywhere;
}

.transfer-meter {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.transfer-meter[hidden] {
  display: none;
}

.meter-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.meter-line span,
.meter-line strong {
  overflow-wrap: anywhere;
}

.flash-wrap {
  width: min(920px, calc(100% - 32px));
  margin: 18px auto 0;
  display: grid;
  gap: 8px;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.flash.error {
  border-color: #f3b0aa;
  color: var(--danger);
}

.flash.ok {
  border-color: #9bd5c9;
  color: var(--primary);
}

.auth-shell {
  justify-items: center;
}

.auth-form {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.auth-form input {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
}

.form-link {
  color: var(--secondary);
  text-align: center;
}

.dashboard,
.transfer-page,
.editor-page {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

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

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

.file-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.file-row h2 {
  overflow-wrap: anywhere;
}

.file-row.just-added {
  border-color: #8fd8cc;
  background: #f3fbf9;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row-actions form {
  margin: 0;
}

.empty {
  padding: 24px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.pickup {
  display: grid;
  gap: 18px;
}

.code-block {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--soft);
  border-radius: 8px;
}

.share-strip {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.share-strip img {
  width: 72px;
  height: 72px;
  display: block;
}

.share-strip span {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.share-strip code {
  display: block;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-block span {
  color: var(--muted);
}

.code-block strong {
  font-size: clamp(32px, 9vw, 56px);
  letter-spacing: 0;
  text-align: center;
}

.action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-grid form {
  margin: 0;
}

.preview-box {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.preview-head h2 {
  margin-bottom: 0;
}

.preview-head span {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-media {
  width: 100%;
  max-height: min(70vh, 720px);
  display: block;
  object-fit: contain;
  border-radius: 8px;
  background: #111827;
}

.preview-audio {
  width: 100%;
}

.preview-frame {
  width: 100%;
  min-height: min(70vh, 680px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.editor-panel {
  display: grid;
  gap: 18px;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.editor-toolbar p {
  color: var(--muted);
  margin-bottom: 0;
}

.editor-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.workbook,
.doc-editor {
  display: grid;
  gap: 18px;
}

.sheet-editor,
.doc-table-editor {
  display: grid;
  gap: 10px;
}

.sheet-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sheet-table {
  border-collapse: collapse;
  min-width: max-content;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid var(--line);
  padding: 0;
}

.sheet-table th {
  min-width: 48px;
  height: 36px;
  padding: 0 8px;
  color: var(--muted);
  background: #f4f7fb;
  font-weight: 700;
}

.sheet-table input {
  width: 148px;
  height: 36px;
  border: 0;
  padding: 0 8px;
  color: var(--text);
  background: #fff;
}

.sheet-table input:focus,
.doc-editor textarea:focus,
.doc-table-row textarea:focus {
  outline: 2px solid #8fd8cc;
  outline-offset: -2px;
}

.doc-editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.doc-editor textarea,
.doc-table-row textarea {
  width: 100%;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  resize: vertical;
}

.doc-table-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.table-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.select-row {
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
}

.archive-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.select-row span {
  overflow-wrap: anywhere;
}

.select-row em {
  color: var(--muted);
  font-style: normal;
  white-space: nowrap;
}

.select-row a {
  color: var(--secondary);
  font-weight: 800;
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    min-height: 58px;
    padding: 12px 16px;
  }

  .home-shell,
  .auth-shell {
    align-items: start;
  }

  .home-shell {
    align-content: start;
  }

  .home-title {
    padding-top: 8px;
  }

  .home-title h1 {
    font-size: 38px;
  }

  .home-title p {
    font-size: 15px;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .section-head {
    display: grid;
  }

  .dropzone {
    min-height: 156px;
  }

  .dashboard-upload,
  .file-row,
  .select-row,
  .settings-grid,
  .share-strip {
    grid-template-columns: 1fr;
  }

  .share-strip img {
    margin: 0 auto;
  }

  .row-actions,
  .action-grid,
  .preview-head,
  .editor-toolbar,
  .editor-actions,
  .upload-status,
  .meter-line {
    display: grid;
    grid-template-columns: 1fr;
  }

  .preview-frame {
    min-height: 420px;
  }

  .code-block {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .primary,
  .secondary,
  .danger {
    width: 100%;
  }
}

.office-body {
  min-height: 100vh;
  overflow: hidden;
}

.office-topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  height: 54px;
  padding: 0 18px;
}

.office-topbar a {
  color: #2563eb;
  font-weight: 700;
  text-decoration: none;
}

.office-topbar strong {
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.office-topbar span {
  color: #64748b;
  font-size: 13px;
}

.office-main {
  height: calc(100vh - 54px);
  margin: 0;
  padding: 0;
}

#onlyoffice-editor {
  height: 100%;
  width: 100%;
}

.office-error {
  margin: 24px;
  padding: 14px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
}

@media (max-width: 760px) {
  .office-topbar {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 74px;
    padding: 10px 14px;
  }

  .office-topbar span {
    display: none;
  }

  .office-main {
    height: calc(100vh - 74px);
  }
}
