:root {
  --bg: #f6f8f8;
  --paper: #ffffff;
  --ink: #17201f;
  --muted: #667370;
  --line: #dfe7e5;
  --teal: #00a99d;
  --teal-dark: #087f78;
  --coral: #ff5b4f;
  --yellow: #f4b943;
  --green-soft: #e7f8f5;
  --shadow: 0 14px 36px rgba(23, 32, 31, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.create-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(0, 169, 157, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(255, 91, 79, 0.1), transparent 34%),
    var(--bg);
}

.admin-page {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 80px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  background: var(--teal);
  border-radius: 8px;
}

.brand-mark svg {
  width: 29px;
  fill: currentColor;
}

.brand strong {
  display: block;
  font-size: 25px;
  line-height: 1.1;
}

.brand small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 12px;
}

.admin-actions {
  align-items: center;
}

.admin-actions .ghost {
  min-height: 52px;
}

.action,
button {
  border: 0;
  cursor: pointer;
}

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 140px;
  min-height: 52px;
  padding: 0 22px;
  color: #fff;
  background: var(--teal);
  border-radius: 8px;
  font-size: 19px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(0, 169, 157, 0.24);
}

.action span {
  font-size: 28px;
  line-height: 1;
}

.action.coral,
.submit.coral {
  background: var(--coral);
  box-shadow: 0 10px 24px rgba(255, 91, 79, 0.2);
}

main {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.create-shell {
  display: grid;
  min-height: 100vh;
  align-content: center;
  gap: 28px;
}

.admin-shell {
  padding-top: 22px;
}

.login-card {
  display: grid;
  min-height: calc(100vh - 130px);
  place-items: center;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.admin-form input {
  min-height: 46px;
  padding: 0 14px;
}

.admin-form.compact {
  margin-top: 18px;
}

.admin-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.admin-library {
  min-height: 360px;
}

.admin-list {
  padding: 8px 14px 14px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.admin-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.admin-row small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.5;
}

.admin-row-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.ghost.danger {
  color: #cf332a;
}

.create-brand {
  justify-self: center;
}

.create-card {
  width: min(720px, 100%);
  justify-self: center;
  padding: 34px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.create-card h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.1;
}

.create-card p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.create-submit {
  min-height: 52px;
  padding: 0 28px;
  font-size: 18px;
}

.created-link {
  margin-top: 24px;
  padding: 16px;
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.created-link > span,
.created-link small {
  color: var(--muted);
  font-size: 13px;
}

.created-link div {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  margin: 10px 0;
}

.created-link input {
  min-height: 42px;
  padding: 0 12px;
}

.intro {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.intro h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3vw, 46px);
  line-height: 1.08;
}

.intro p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.expiry {
  min-width: 260px;
  padding: 18px 20px;
  background: #fff8e4;
  border: 1px solid #f4df9f;
  border-radius: 8px;
}

.expiry span,
.limit,
.autosave {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.expiry strong {
  display: block;
  margin-top: 8px;
  font-size: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 14px;
}

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

.panel {
  padding: 18px;
}

.panel-head,
.library-head,
.form-row,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel h2,
.sidebar h2 {
  margin: 0;
  font-size: 21px;
}

.panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dropzone {
  display: grid;
  min-height: 158px;
  margin-top: 18px;
  place-items: center;
  padding: 24px;
  color: var(--teal-dark);
  text-align: center;
  background: linear-gradient(180deg, #fbffff, #f2fbfa);
  border: 1.5px dashed var(--teal);
  border-radius: 8px;
  cursor: pointer;
}

.dropzone.dragging {
  background: #e7f8f5;
  border-color: var(--teal-dark);
}

.dropzone input {
  display: none;
}

.dropzone strong {
  margin-top: 8px;
  font-size: 17px;
}

.dropzone small {
  margin-top: 6px;
  color: var(--muted);
}

.cloud {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  color: var(--teal);
}

.cloud svg {
  width: 54px;
  fill: currentColor;
}

.cloud path + path {
  fill: none;
  stroke: #fff;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-types {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.file-types span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #344240;
  font-size: 14px;
  background: #fff;
}

.file-types b,
.file-icon {
  display: inline-grid;
  width: 25px;
  height: 25px;
  place-items: center;
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
}

.doc { background: #1976d2; }
.sheet { background: #1f9a52; }
.pdf { background: #ef3b32; }
.image { background: #f28a16; }
.text { background: #009d9a; }
.other { background: #7d8a87; }

textarea,
input[type="text"],
input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea:focus,
input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(0, 169, 157, 0.12);
}

#uploadNote {
  min-height: 64px;
  padding: 12px 14px;
  resize: vertical;
}

.ghost,
.submit {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 750;
}

.ghost {
  color: #33413f;
  background: #fff;
  border: 1px solid var(--line);
}

.submit {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 8px 18px rgba(0, 169, 157, 0.18);
}

#selectedText {
  flex: 1;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.editor-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

#textTitle,
#textNote {
  min-height: 44px;
  padding: 0 14px;
}

#textContent {
  min-height: 206px;
  padding: 16px;
  resize: vertical;
  line-height: 1.65;
}

.library {
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  margin-top: 14px;
  overflow: hidden;
}

.sidebar {
  padding: 18px;
  border-right: 1px solid var(--line);
}

.filter {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  margin-top: 8px;
  padding: 0 12px;
  color: #344240;
  background: transparent;
  border-radius: 8px;
  text-align: left;
}

.filter.active {
  color: var(--teal-dark);
  background: var(--green-soft);
  font-weight: 800;
}

.filter span {
  min-width: 28px;
  padding: 3px 8px;
  color: #50605d;
  background: #edf2f1;
  border-radius: 999px;
  text-align: center;
}

.table-wrap {
  min-width: 0;
}

.library-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.search {
  position: relative;
  flex: 1;
}

.search span {
  position: absolute;
  top: 9px;
  left: 12px;
  color: var(--muted);
  font-size: 20px;
}

.search input {
  min-height: 42px;
  padding: 0 14px 0 42px;
}

.table {
  overflow-x: auto;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(280px, 1.6fr) 100px 100px 110px 170px 130px;
  align-items: center;
  min-width: 920px;
  border-bottom: 1px solid var(--line);
}

.table-row > span,
.table-row > div {
  padding: 13px 14px;
}

.table-title {
  color: #53625f;
  background: #fbfcfc;
  font-size: 13px;
  font-weight: 800;
}

.file-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-name strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name small {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-pill {
  display: inline-flex;
  padding: 4px 9px;
  color: #0b6963;
  background: var(--green-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  color: var(--teal-dark);
  background: #eefaf8;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.empty {
  display: none;
  padding: 54px 20px;
  color: var(--muted);
  text-align: center;
}

.empty strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 20px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  transform: translateY(18px);
  min-width: 220px;
  max-width: 380px;
  padding: 14px 16px;
  color: #fff;
  background: #17201f;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.expired-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 248, 248, 0.94);
  backdrop-filter: blur(14px);
}

.expired-mask div {
  width: min(560px, 100%);
  padding: 30px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.expired-mask h1 {
  margin: 0 0 12px;
  font-size: 32px;
}

.expired-mask p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 980px) {
  .topbar,
  .intro,
  .panel-head,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .actions,
  .workspace,
  .library,
  .created-link div {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .action {
    min-width: 0;
  }

  .file-types {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  main {
    width: min(100vw - 20px, 1500px);
  }

  .topbar {
    padding: 12px 14px;
  }

  .brand strong {
    font-size: 21px;
  }

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

  .workspace,
  .library {
    gap: 10px;
  }

  .file-types {
    grid-template-columns: 1fr;
  }
}
