:root {
  --bg: #0f1218;
  --surface: #171c26;
  --border: #2a3142;
  --text: #e8eaef;
  --muted: #8b93a5;
  --accent: #3d8fd1;
  --accent-hover: #5299d6;
  --danger: #e07070;
  --radius: 12px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.layout {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.layout-wide {
  max-width: 960px;
}

.header {
  margin-bottom: 28px;
}

.title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hint code {
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 6px;
}

.hidden {
  display: none !important;
}

.tg-widget-wrap {
  min-height: 44px;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.field-label-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field-label-icon {
  flex-shrink: 0;
  opacity: 0.85;
}

.select {
  min-width: 200px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--text);
}

.error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.preview-wrap {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.preview-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.link-download {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
}

.link-download:hover {
  text-decoration: underline;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.card-title-spaced {
  margin-bottom: 18px;
}

.section-heading {
  margin: 22px 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.hint-tight {
  margin-top: 0;
  margin-bottom: 14px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.field-full {
  width: 100%;
}

.composite-file-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.input-file {
  max-width: min(100%, 320px);
}

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

label.field.field-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.field-inline .field-label {
  min-width: 52px;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.field-time {
  flex: 0 0 auto;
}

.input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}

.input-sm {
  padding: 8px 10px;
  font-size: 0.9rem;
}

.textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  resize: vertical;
  min-height: 52px;
}

.textarea-sm {
  min-height: 44px;
  font-size: 0.95rem;
}

.select-sm {
  min-width: 0;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.muted-small {
  font-size: 0.75rem;
  color: var(--muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.message-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 12px;
}

.message-rows-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.msg-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.2);
}

.msg-row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.msg-img-file-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.msg-img-file-row input[type='file'] {
  max-width: 100%;
  font-size: 0.85rem;
  color: var(--muted);
}

.msg-img-preview-wrap {
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  max-width: 144px;
}

.msg-img-preview-wrap.hidden {
  display: none;
}

.msg-img-preview {
  display: block;
  width: 100%;
  height: auto;
  max-height: 108px;
  object-fit: contain;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

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