:root {
  --ink: #171713;
  --muted: #737167;
  --paper: #f3f0e8;
  --card: #fffefa;
  --line: #ded9cc;
  --accent: #ff4d4f;
  --accent-dark: #d9363e;
  --success: #1f8b5c;
  --blue: #2768d8;
  --shadow: 0 24px 80px rgba(34, 31, 24, 0.085);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 2%, rgba(255, 77, 79, 0.12), transparent 31rem),
    radial-gradient(circle at 95% 46%, rgba(39, 104, 216, 0.07), transparent 32rem),
    linear-gradient(145deg, #f8f6f0 0%, var(--paper) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.58; }

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

.hero {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  flex: 0 0 66px;
  width: 66px;
  height: 66px;
  place-items: center;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(145deg, #ff686a, var(--accent-dark));
  box-shadow: 0 16px 34px rgba(255, 77, 79, 0.25);
  font-size: 31px;
  font-weight: 700;
}

.eyebrow, .section-kicker {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0.15em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(31px, 5vw, 46px); letter-spacing: -0.04em; }
h2 { letter-spacing: -0.02em; }
h3 { margin-bottom: 5px; font-size: 19px; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 16px; }

.card, .workflow-card {
  border: 1px solid rgba(222, 217, 204, 0.86);
  background: rgba(255, 254, 250, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.card { padding: clamp(24px, 5vw, 42px); border-radius: 28px; }

.auth-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px;
  margin-bottom: 36px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #f8f6f0;
}

.auth-panel.logged-in { border-color: rgba(31, 139, 92, 0.28); background: rgba(31, 139, 92, 0.055); }
.auth-panel.waiting { border-color: rgba(255, 77, 79, 0.3); background: rgba(255, 77, 79, 0.045); }
.auth-title-row, .auth-actions, .row-actions, .workspace-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.auth-title-row { margin-bottom: 4px; }
.auth-title-row h2 { margin: 0; font-size: 15px; }
.auth-copy p { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.auth-copy .auth-safety { margin-top: 3px; color: #918f85; font-size: 11px; }
.auth-actions { justify-content: flex-end; }

.auth-badge, .draft-badge, .state-badge, .platform-state, .step-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 730;
  white-space: nowrap;
}

.auth-badge { padding: 3px 8px; color: var(--muted); background: rgba(111, 110, 101, 0.1); }
.logged-in .auth-badge { color: var(--success); background: rgba(31, 139, 92, 0.1); }
.waiting .auth-badge { color: var(--accent-dark); background: rgba(255, 77, 79, 0.1); }

.section-heading, .workspace-header, .split-heading, .final-layout {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.section-heading { margin-bottom: 21px; }
.section-heading h2 { margin: 0; font-size: 24px; }
.step-pill { padding: 7px 11px; color: var(--accent-dark); background: rgba(255, 77, 79, 0.09); }
.muted-pill { color: var(--muted); background: #efede6; }

.field-label { display: block; margin: 18px 0 8px; font-size: 13px; font-weight: 700; }
.field-wrap { position: relative; }

textarea, input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea:focus, input:focus, select:focus { border-color: rgba(255, 77, 79, 0.65); box-shadow: 0 0 0 4px rgba(255, 77, 79, 0.09); }
textarea { padding: 14px 16px; resize: vertical; line-height: 1.58; }
#share-text { min-height: 116px; padding-right: 82px; }
.brief-field { min-height: 84px; }
input { min-width: 0; padding: 13px 14px; }
select { width: 100%; padding: 13px 14px; background: #fff; }
.field-hint { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.optional-label { margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 600; }
.path-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.field-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
}

.text-button {
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  color: var(--accent-dark);
  background: rgba(255, 77, 79, 0.09);
  font-weight: 670;
}
.clear-button { color: var(--muted); background: rgba(111, 110, 101, 0.09); }

.primary-button, .secondary-button, .publish-button {
  border-radius: 13px;
  font-weight: 690;
  transition: transform 150ms ease, background 150ms ease;
}

.primary-button:hover:not(:disabled), .secondary-button:hover:not(:disabled) { transform: translateY(-1px); }
.primary-button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  margin-top: 22px;
  padding: 15px 18px;
  border: 0;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(255, 77, 79, 0.19);
}
.primary-button:hover:not(:disabled) { background: var(--accent-dark); }
.secondary-button { padding: 11px 15px; border: 1px solid var(--line); color: var(--ink); background: #fff; white-space: nowrap; }
.accent-button { border-color: rgba(255, 77, 79, 0.24); color: var(--accent-dark); }
.compact-button { width: auto; min-width: 170px; margin-top: 0; gap: 22px; }
.link-button { padding: 7px 4px; border: 0; color: var(--muted); background: transparent; font-size: 12px; }
.danger-link { color: var(--accent-dark); }

.inline-status {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-top: 18px;
  padding: 15px 16px;
  border-radius: 14px;
  background: #f6f4ee;
}
.inline-status[hidden], .workspace[hidden] { display: none; }
.inline-status p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.status-icon { flex: 0 0 12px; width: 12px; height: 12px; margin-top: 3px; border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.inline-status.success .status-icon { border: 0; background: var(--success); animation: none; }
.inline-status.error .status-icon { border: 0; background: var(--accent); animation: none; }

.workspace { margin-top: 28px; }
.workspace-header { align-items: center; margin-bottom: 16px; padding: 0 5px; }
.workspace-header h2 { margin-bottom: 5px; font-size: 27px; }
.task-id { max-width: 760px; margin: 0; overflow: hidden; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.state-badge { padding: 7px 11px; color: #8a621c; background: #fff0ce; }
.state-badge.ready { color: var(--success); background: rgba(31, 139, 92, 0.1); }

.workflow-grid { display: grid; grid-template-columns: minmax(0, .84fr) minmax(0, 1.16fr); gap: 18px; }
.workflow-card { position: relative; margin-top: 18px; padding: 28px; overflow: hidden; border-radius: 22px; }
.card-number { position: absolute; top: 16px; right: 18px; color: #d6d1c5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 760; }
.card-heading { padding-right: 32px; }
.card-heading p { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
code { padding: 2px 5px; border-radius: 6px; background: #f1eee6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }

.video-shell { position: relative; display: grid; min-height: 260px; margin-top: 18px; place-items: center; overflow: hidden; border-radius: 16px; background: #171717; }
.video-shell video { display: block; width: 100%; max-height: 440px; background: #111; }
.video-shell video[hidden] { display: none; }
.video-empty { max-width: 260px; padding: 24px; color: #aaa69d; font-size: 12px; line-height: 1.6; text-align: center; }
.video-empty[hidden] { display: none; }
.file-list { margin: 14px 0 0; padding-left: 19px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.8; }

.copy-card .field-label:first-of-type { margin-top: 16px; }
.copy-card textarea { min-height: 72px; }
.source-copy-summary { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #faf9f5; color: var(--muted); font-size: 11px; line-height: 1.55; }
.source-copy-summary p { margin: 0; }
.source-copy-summary p + p { margin-top: 4px; }
.source-copy-summary strong { color: var(--ink); }
.draft-badge { padding: 5px 9px; color: var(--blue); background: rgba(39, 104, 216, 0.09); }
.row-actions { justify-content: space-between; margin-top: 17px; }
.save-message, .final-message { min-height: 18px; margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.success-text { color: var(--success); }

.final-layout { align-items: center; }
.final-layout > * { flex: 1; }
.final-card { padding: 32px; }
.final-preview { flex: 0 0 min(42%, 390px); min-height: 220px; margin-top: 0; }
.final-actions { justify-content: flex-start; margin-top: 22px; }

.publish-heading { margin-bottom: 16px; }
.platform-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.platform-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #faf9f5; }
.platform-row p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.platform-icon { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 10px; color: #fff; font-size: 20px; font-weight: 760; }
.instagram-icon { background: linear-gradient(135deg, #6a43d6, #ef4e7b, #f1a04a); }
.facebook-icon { background: #1877f2; }
.platform-state { padding: 5px 8px; color: var(--muted); background: #efede6; }
.publish-button { width: 100%; margin-top: 14px; padding: 14px; border: 1px dashed #d6d1c5; color: var(--muted); background: #f2f0e9; }

footer { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 24px 8px 0; color: var(--muted); font-size: 12px; text-align: center; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(31, 139, 92, 0.1); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 850px) {
  .workflow-grid { grid-template-columns: 1fr; }
  .final-layout { display: grid; grid-template-columns: 1fr; }
  .final-preview { width: 100%; margin-top: 22px; }
}

@media (max-width: 640px) {
  .shell { padding-top: 34px; }
  .hero { align-items: flex-start; }
  .brand-mark { flex-basis: 52px; width: 52px; height: 52px; border-radius: 15px; font-size: 25px; }
  .auth-panel, .path-row, .platform-grid { grid-template-columns: 1fr; }
  .auth-actions { justify-content: flex-start; }
  .workspace-header, .section-heading { align-items: flex-start; flex-direction: column; }
  .workspace-actions { width: 100%; justify-content: space-between; }
  .workflow-card { padding: 23px; }
  .platform-row { grid-template-columns: auto 1fr; }
  .platform-state { grid-column: 2; justify-self: start; }
  .row-actions { align-items: stretch; flex-direction: column; }
  .compact-button { width: 100%; }
}

/* Multi-page application shell */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 26px;
  min-height: 62px;
  padding: 0 max(20px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid rgba(222, 217, 204, .78);
  background: rgba(248, 246, 240, .9);
  backdrop-filter: blur(18px);
}
.nav-brand { display: flex; align-items: center; gap: 9px; color: var(--accent-dark); font-weight: 800; text-decoration: none; }
.nav-brand span { color: var(--ink); }
.nav-links { display: flex; align-items: stretch; gap: 4px; height: 62px; }
.nav-links a { display: grid; place-items: center; padding: 0 13px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 650; text-decoration: none; }
.nav-links a:hover, .nav-links a.active { color: var(--ink); border-bottom-color: var(--accent); }
.nav-account { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.page-shell { padding-top: 42px; }
.page-header { margin-bottom: 27px; }
.page-header h1 { margin-bottom: 7px; }
.two-column-layout { display: grid; grid-template-columns: minmax(0, .92fr) minmax(380px, 1.08fr); gap: 20px; align-items: start; }
.admin-columns { grid-template-columns: minmax(0, .9fr) minmax(400px, 1.1fr); }
.users-layout { grid-template-columns: minmax(320px, .72fr) minmax(470px, 1.28fr); }
.history-card { min-height: 420px; }
.empty-state { padding: 55px 20px; border: 1px dashed var(--line); border-radius: 15px; color: var(--muted); font-size: 13px; text-align: center; }
.job-list, .task-list, .user-list { display: grid; gap: 10px; }
.job-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #faf9f5; }
.job-item strong, .task-list-item strong, .user-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-item p, .task-list-item p, .user-item p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.job-state { display: block; margin-top: 5px; color: #8a621c; font-size: 11px; }
.job-failed .job-state { color: var(--accent-dark); }
.job-ready .job-state { color: var(--success); }
.job-actions { display: flex; align-items: center; gap: 6px; }
.primary-link { padding: 10px 13px; border-radius: 11px; color: #fff; background: var(--accent); font-size: 12px; font-weight: 720; text-decoration: none; white-space: nowrap; }
.primary-link:hover { background: var(--accent-dark); }
.task-list-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: #faf9f5; text-decoration: none; transition: transform 150ms ease, border-color 150ms ease; }
.task-list-item:hover { transform: translateY(-1px); border-color: rgba(255, 77, 79, .35); }
.path-summary { margin-top: 19px; padding: 12px 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #faf9f5; }
.path-summary span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.path-summary strong { display: block; overflow: hidden; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.user-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #faf9f5; }
.user-disabled { opacity: .62; }
.user-avatar { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; color: var(--accent-dark); background: rgba(255, 77, 79, .1); font-weight: 800; }
.user-state { padding: 5px 8px; border-radius: 999px; color: var(--muted); background: #efede6; font-size: 10px; font-weight: 700; }
.user-state.active { color: var(--success); background: rgba(31, 139, 92, .1); }
.user-actions { grid-column: 2 / -1; display: flex; gap: 14px; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 8px; }
.form-message { min-height: 18px; margin: 10px 0 0; color: var(--accent-dark); font-size: 12px; }
.back-link { display: inline-block; margin: 0 0 20px; color: var(--muted); font-size: 12px; text-decoration: none; }
.back-link:hover { color: var(--ink); }
.task-detail-header { margin-bottom: 10px; }
.task-detail-header h1 { margin-bottom: 6px; }

.login-body { display: grid; place-items: center; }
.login-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 430px); align-items: center; gap: clamp(45px, 9vw, 130px); width: min(1000px, calc(100% - 32px)); min-height: 100vh; padding: 40px 0; }
.login-brand .brand-mark { margin-bottom: 25px; }
.login-brand h1 { max-width: 540px; }
.login-card { padding: 34px; }
.login-card h2 { margin-bottom: 22px; font-size: 27px; }

@media (max-width: 880px) {
  .two-column-layout, .admin-columns, .users-layout { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: auto 1fr; padding: 0 16px; }
  .nav-links { grid-column: 1 / -1; grid-row: 2; order: 3; height: 43px; overflow-x: auto; }
  .nav-links a { padding: 0 10px; white-space: nowrap; }
  .nav-account { justify-self: end; }
  .login-shell { grid-template-columns: 1fr; max-width: 500px; align-content: center; gap: 30px; }
  .login-brand .brand-mark { margin-bottom: 18px; }
}

@media (max-width: 560px) {
  .page-shell { width: min(100% - 20px, 1120px); padding-top: 28px; }
  .topbar { min-height: 55px; }
  .nav-brand span { display: none; }
  .nav-account > span { display: none; }
  .card { padding: 22px 18px; border-radius: 22px; }
  .job-item { grid-template-columns: 1fr; }
  .job-actions { justify-content: space-between; }
  .primary-link { flex: 1; text-align: center; }
  .task-detail-header { align-items: flex-start; }
  .task-detail-header .workspace-actions { align-items: stretch; flex-direction: column; }
  .login-brand h1 { font-size: 34px; }
}
