:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17202a;
  background: #f5f7f8;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
}

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

button,
.file-button {
  min-height: 38px;
  border: 1px solid #c9d1d9;
  border-radius: 9px;
  padding: 0 13px;
  color: inherit;
  background: #ffffff;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  background: #f0f3f5;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.file-button:focus-within {
  outline: 3px solid rgba(29, 155, 240, 0.28);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.primary {
  border-color: #17202a;
  color: #ffffff;
  background: #17202a;
}

.primary:hover {
  background: #2b3640;
}

.shell {
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #536471;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.75rem);
  letter-spacing: -0.04em;
}

.intro {
  max-width: 620px;
  margin: 8px 0 0;
  color: #536471;
  line-height: 1.5;
}

.save-status {
  flex: 0 0 auto;
  margin: 6px 0 0;
  color: #536471;
  font-size: 0.82rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 5px;
  color: #536471;
  font-size: 0.78rem;
}

.field select,
.field input {
  min-height: 38px;
  border: 1px solid #c9d1d9;
  border-radius: 9px;
  padding: 0 10px;
  color: #17202a;
  background: #ffffff;
}

.compact select {
  min-width: 145px;
}

.custom-limit-field input {
  width: 118px;
}

.thread-summary {
  margin: 0 0 10px auto;
  color: #536471;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.thread-list {
  display: grid;
  gap: 14px;
}

.post-card {
  display: grid;
  gap: 12px;
  border: 1px solid #d8dee4;
  border-radius: 14px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.post-card.dragging {
  border-color: #1d9bf0;
  box-shadow: 0 0 0 3px rgba(29, 155, 240, 0.14);
}

.post-card.over-limit {
  border-color: #f4212e;
}

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

.post-counter {
  margin-left: auto;
  color: #536471;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.post-card.over-limit .post-counter {
  color: #d20f1f;
  font-weight: 700;
}

.post-actions {
  display: flex;
  gap: 4px;
}

.icon-button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 9px;
}

.post-text {
  width: 100%;
  min-height: 126px;
  resize: vertical;
  border: 0;
  border-radius: 8px;
  padding: 4px;
  color: #17202a;
  background: transparent;
  font-size: 1.04rem;
  line-height: 1.5;
}

.post-text::placeholder {
  color: #7f8c96;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.image-preview {
  position: relative;
  min-width: 0;
  margin: 0;
}

.image-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 10px;
  background: #e8ecef;
}

.remove-image {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 32px;
  min-height: 32px;
  border-color: rgba(255, 255, 255, 0.7);
  padding: 0;
  color: #ffffff;
  background: rgba(15, 20, 25, 0.72);
}

.remove-image:hover {
  background: rgba(15, 20, 25, 0.9);
}

.image-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: #536471;
  font-size: 0.78rem;
}

.file-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  :root {
    color: #e7e9ea;
    background: #000000;
  }

  button,
  .file-button,
  .field select,
  .field input,
  .post-card {
    border-color: #2f3336;
    color: #e7e9ea;
    background: #16181c;
  }

  button:hover,
  .file-button:hover {
    background: #202327;
  }

  .primary {
    border-color: #eff3f4;
    color: #0f1419;
    background: #eff3f4;
  }

  .primary:hover {
    background: #d7dbdc;
  }

  .eyebrow,
  .intro,
  .save-status,
  .field,
  .thread-summary,
  .post-counter,
  .image-controls {
    color: #8b98a5;
  }

  .post-text {
    color: #e7e9ea;
  }

  .post-text::placeholder {
    color: #71767b;
  }

  .image-preview img {
    background: #202327;
  }
}

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

  .page-header {
    display: block;
  }

  .save-status {
    margin-top: 12px;
  }

  .thread-summary {
    width: 100%;
    margin: 4px 0 0;
  }

  .post-header {
    flex-wrap: wrap;
  }

  .post-actions {
    width: 100%;
  }
}
