:root {
  --bg: #fff9fc;
  --surface: #ffe5ef;
  --surface-strong: #ffd1e4;
  --primary: #ff8fb1;
  --primary-dark: #ff5f8d;
  --text-strong: #412030;
  --text: #5d3d4a;
  --muted: #b67c92;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(255, 143, 177, 0.18);
  --shadow-soft: 0 8px 20px rgba(255, 143, 177, 0.12);
  --transition: 0.25s ease;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0;
  font-family: "Noto Sans SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 20%, #fff0f6 0%, #fff 35%),
              radial-gradient(circle at 80% 0%, #ffe3f0 0%, #fff 45%),
              var(--bg);
  color: var(--text);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  gap: 12px;
  flex-wrap: wrap;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.logo { height: 44px; max-width: 140px; width: auto; object-fit: contain; }
.logo-left { margin-right: 4px; }
.logo-right { opacity: 0.92; }

.user-meta { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.tag {
  padding: 6px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  box-shadow: var(--shadow-soft);
}

.link {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
}
.link:hover { text-decoration: underline; }

.layout {
  width: min(1100px, 92vw);
  margin: 0 auto 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

.card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.hero {
  background: linear-gradient(135deg, rgba(255, 143, 177, 0.2), rgba(255, 143, 177, 0.05));
}

.eyebrow {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: 700;
}

h1, h2 { margin: 0 0 8px; color: var(--text-strong); }
.subtext { margin: 0; color: var(--muted); }

.card-header { margin-bottom: 12px; }

.upload-card { display: flex; flex-direction: column; gap: 12px; }
.upload-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.upload-field {
  position: relative;
  overflow: hidden;
  padding: 12px 16px;
  border: 1.5px dashed var(--primary-dark);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: rgba(255, 143, 177, 0.06);
  color: var(--text-strong);
  min-width: 240px;
  text-align: center;
}
.upload-field input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  line-height: 1.1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn.text {
  background: #fff5fa;
  color: #b24900;
  padding: 10px 14px;
  border: 1px solid #f0c2d4;
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
}
.btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-soft);
}
.btn.danger {
  background: #fff0f2;
  color: #c0392b;
  border: 1px solid #f3c2c9;
}
.btn.text:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.text:active { transform: translateY(0); }
.btn.danger:hover { background: #ffe7ec; }
.btn.primary:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.primary:active { transform: translateY(0); }
.btn.w-100 { width: 100%; }

.upload-preview {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  width: 100%;
}
.upload-chip {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fff5fa;
  border: 1px solid #f7d6e5;
  box-shadow: var(--shadow-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.upload-chip .name {
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-chip .meta { color: var(--muted); font-size: 12px; }

.upload-progress {
  margin-top: 10px;
  background: #fff5fa;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid #f7d6e5;
}
.progress-bar {
  height: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  width: 0%;
  border-radius: 999px;
  transition: width 0.2s ease;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-form input {
  border: 1px solid #f1c7d8;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fffafc;
  font-size: 14px;
}

.table-wrap { overflow-x: auto; }
.file-table { width: 100%; border-collapse: collapse; }
.file-table th, .file-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #f0d7e3;
  text-align: left;
}
.file-table th {
  background: #fff5fa;
  color: var(--text-strong);
  font-size: 14px;
}
.file-table td { font-size: 14px; }
.icon { margin-right: 8px; }
.filename { display: inline-block; max-width: 340px; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: break-all; }
.empty { text-align: center; color: var(--muted); padding: 18px 0; }
.muted { color: var(--muted); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
}

.modal {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  width: min(520px, 90vw);
}

.modal-large { width: min(900px, 95vw); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-select {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #f1c7d8;
  background: #fffafc;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.editor-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.editor-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 360px;
}

#textEditor {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid #f1c7d8;
  padding: 12px;
  font-family: "SFMono-Regular", ui-monospace, Menlo, monospace;
  background: #fffafc;
  resize: none;
}

.editor-preview {
  border: 1px solid #f1c7d8;
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fffafc;
  overflow: auto;
  font-size: 14px;
}

.page-auth .auth-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.auth-card { width: min(420px, 92vw); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form-label { display: flex; flex-direction: column; gap: 6px; color: var(--text-strong); font-weight: 600; }
.form-label input {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #f1c7d8;
  background: #fffafc;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}
.form-label input:focus { border-color: var(--primary-dark); box-shadow: 0 0 0 3px rgba(255, 143, 177, 0.25); }

.alert { min-height: 18px; color: #d1435b; font-weight: 600; margin-bottom: 4px; }

.site-footer {
  text-align: center;
  padding: 16px 0 24px;
  color: var(--muted);
  font-size: 13px;
}
.site-footer a { color: var(--primary-dark); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .upload-form { flex-direction: column; align-items: stretch; }
  .btn.primary { width: 100%; text-align: center; }
  .filename { max-width: 100%; white-space: normal; }
  .upload-preview { grid-template-columns: 1fr; }
  .actions-row { flex-direction: column; }
  .file-table thead { display: none; }
  .file-table, .file-table tbody, .file-table tr, .file-table td { display: block; width: 100%; }
  .file-table tr {
    margin-bottom: 14px;
    border: 1px solid #f5d7e8;
    border-radius: 12px;
    padding: 10px 10px 6px;
    box-shadow: var(--shadow-soft);
  }
  .file-table td { border: none; padding: 6px 2px; }
  .file-table td.actions { padding-top: 8px; }
  .actions { flex-direction: row; justify-content: flex-start; gap: 8px; }
  .actions .btn { flex: 1 1 auto; min-width: 0; }
  .table-wrap { overflow: visible; }
  .editor-body { grid-template-columns: 1fr; min-height: 280px; }
}
