:root {
  --ink: #171914;
  --muted: #71766b;
  --line: #dfe2d9;
  --paper: #ffffff;
  --canvas: #f4f4ef;
  --accent: #c8ff2e;
  --accent-hover: #b8ef1f;
  --danger: #b9362b;
  --danger-bg: #fff0ed;
  --success: #287245;
  --success-bg: #ecf8ef;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(200, 255, 46, 0.22), transparent 25rem),
    var(--canvas);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100% - 32px, 500px);
  margin: 0 auto;
  padding: 46px 0 30px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 38px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--accent);
  font-size: 22px;
  font-weight: 850;
}

.auth-card {
  min-height: 510px;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  box-shadow: 0 20px 60px rgba(25, 29, 19, 0.08);
}

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

h1 {
  margin: 0;
  font-size: clamp(32px, 7vw, 44px);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.lead {
  margin: 18px 0 30px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 14px;
  font-weight: 720;
}

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

.field input,
.field select {
  height: 54px;
}

.field textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #7d9f21;
  box-shadow: 0 0 0 4px rgba(200, 255, 46, 0.28);
}

.field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 780;
  transition:
    background 150ms ease,
    transform 150ms ease,
    opacity 150ms ease;
}

.primary-button {
  color: var(--ink);
  background: var(--accent);
}

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

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.switch {
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.switch a {
  color: var(--ink);
  font-weight: 760;
  text-underline-offset: 3px;
}

.notice {
  margin: 0 0 20px;
  padding: 13px 15px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
}

.notice.error {
  color: var(--danger);
  background: var(--danger-bg);
}

.notice.success {
  color: var(--success);
  background: var(--success-bg);
}

.loading {
  display: flex;
  min-height: 420px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.spinner {
  width: 19px;
  height: 19px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.account-grid {
  display: grid;
  gap: 14px;
  margin: 30px 0;
}

.account-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafbf7;
}

.account-item small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
}

.account-item strong {
  overflow-wrap: anywhere;
}

.security-note {
  max-width: 410px;
  margin: 22px auto 0;
  color: #8b9085;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.dashboard-shell {
  width: min(100% - 40px, 1240px);
  padding-top: 28px;
}

.dashboard-shell > .brand {
  margin-bottom: 22px;
}

.dashboard-card {
  display: grid;
  min-height: 720px;
  grid-template-columns: 230px minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
}

.dashboard-sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 34px;
  padding: 30px 24px;
  border-right: 1px solid var(--line);
  background: #f7f8f3;
}

.sidebar-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workspace-name {
  display: block;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-nav {
  display: grid;
  gap: 7px;
}

.dashboard-nav a {
  padding: 11px 12px;
  border-radius: 11px;
  color: #62675d;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.dashboard-nav a:hover,
.dashboard-nav a.active {
  color: var(--ink);
  background: #e9ece2;
}

.sidebar-account {
  display: grid;
  gap: 9px;
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.sidebar-account button {
  width: max-content;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: none;
  cursor: pointer;
  font-weight: 720;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dashboard-main {
  min-width: 0;
  padding: 36px;
}

.dashboard-header,
.section-heading,
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dashboard-header h1 {
  font-size: clamp(34px, 4vw, 48px);
}

.primary-button.compact {
  min-height: 44px;
  padding: 0 18px;
  font-size: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 30px 0 40px;
}

.stat-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fafbf8;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.stat-card strong {
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.04em;
}

.stat-card.planned {
  background: #fff7dd;
}

.stat-card.ready {
  background: #edf8ed;
}

.stat-card.error {
  background: var(--danger-bg);
}

.dashboard-section {
  padding-top: 28px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 20px;
}

.dashboard-section + .dashboard-section {
  margin-top: 42px;
}

.section-heading {
  align-items: end;
  margin-bottom: 18px;
}

.section-heading .eyebrow {
  margin-bottom: 6px;
}

.section-heading h2,
.dialog-heading h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.section-heading > span {
  color: var(--muted);
  font-size: 12px;
}

.post-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 17px;
  overflow: hidden;
}

.post-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 18px;
  min-height: 82px;
  align-items: center;
  padding: 14px 18px;
  background: #fff;
}

.post-row + .post-row {
  border-top: 1px solid var(--line);
}

.post-date {
  display: grid;
  justify-items: center;
  padding-right: 16px;
  border-right: 1px solid var(--line);
}

.post-date strong {
  font-size: 21px;
}

.post-date span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.post-content {
  min-width: 0;
}

.post-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.post-title-line > strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-meta {
  display: flex;
  gap: 6px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.status-badge,
.platform-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge {
  padding: 5px 8px;
  color: #666b61;
  background: #eef0ea;
  font-size: 10px;
  font-weight: 760;
}

.status-badge.scheduled {
  color: #855f00;
  background: #fff1bf;
}

.status-badge.published {
  color: var(--success);
  background: var(--success-bg);
}

.status-badge.failed,
.status-badge.partial {
  color: var(--danger);
  background: var(--danger-bg);
}

.platform-badge {
  padding: 4px 7px;
  background: #f0f2ed;
  font-size: 10px;
  font-weight: 720;
}

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

.connection-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.platform-logo {
  display: grid;
  width: 42px;
  height: 42px;
  grid-row: span 2;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: #1e201c;
  font-size: 12px;
  font-weight: 820;
}

.platform-logo.telegram {
  background: #269ed2;
}

.platform-logo.max {
  background: #5e75e8;
}

.connection-card div {
  display: grid;
  gap: 4px;
}

.connection-card div span {
  color: var(--muted);
  font-size: 12px;
}

.connection-card button {
  grid-column: 2;
  width: max-content;
  padding: 0;
  border: 0;
  color: #8a8e85;
  background: none;
  font-size: 12px;
  font-weight: 720;
}

.connection-card button:not(:disabled) {
  color: var(--ink);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.connection-help {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.empty-state {
  display: grid;
  gap: 7px;
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.composer-dialog {
  width: min(100% - 24px, 590px);
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  box-shadow: 0 30px 100px rgba(15, 18, 11, 0.26);
}

.composer-dialog::backdrop {
  background: rgba(20, 22, 18, 0.45);
  backdrop-filter: blur(4px);
}

.composer-panel {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.dialog-heading {
  align-items: center;
}

.dialog-heading .eyebrow {
  margin-bottom: 5px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

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

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 500px);
    padding-top: 24px;
  }

  .brand {
    margin-bottom: 22px;
  }

  .auth-card {
    min-height: 0;
    padding: 28px 22px;
    border-radius: 22px;
  }

  .dashboard-shell {
    width: min(100% - 16px, 1240px);
  }

  .dashboard-card {
    display: block;
  }

  .dashboard-sidebar {
    gap: 18px;
    padding: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .dashboard-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard-nav a {
    padding: 9px 4px;
    font-size: 12px;
    text-align: center;
  }

  .sidebar-account {
    display: none;
  }

  .dashboard-main {
    padding: 24px 18px;
  }

  .dashboard-header {
    display: grid;
  }

  .dashboard-header .primary-button {
    width: 100%;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .post-title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
