/* Styles for the post form (web/static/index.html). Phone first, one column.
   Telegram sets the --tg-theme-* variables. The fallbacks below apply outside Telegram. */

:root {
  --page-bg: var(--tg-theme-bg-color, #ffffff);
  --page-text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #707579);
  --button: var(--tg-theme-button-color, #3390ec);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --problem: var(--tg-theme-destructive-text-color, #e53935);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: var(--tg-theme-bg-color, #212121);
    --page-text: var(--tg-theme-text-color, #ffffff);
    --hint: var(--tg-theme-hint-color, #aaaaaa);
    --button: var(--tg-theme-button-color, #8774e1);
    --button-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #2c2c2e);
    --problem: var(--tg-theme-destructive-text-color, #ff6b6b);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--page-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

.hidden {
  display: none !important;
}

.hint {
  color: var(--hint);
  margin-top: 0.25rem;
}

.problem {
  color: var(--problem);
  font-weight: 600;
  margin-top: 0.25rem;
}

#caption-count.over {
  color: var(--problem);
  font-weight: 600;
}

#loading {
  color: var(--hint);
  margin-bottom: 1rem;
}

.banner {
  background: var(--secondary-bg);
  border-left: 4px solid var(--problem);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  margin-bottom: 1rem;
}

.notice {
  background: var(--secondary-bg);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

label {
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  color: var(--page-text);
  background: var(--page-bg);
  border: 1px solid var(--hint);
  border-radius: 8px;
}

textarea {
  resize: vertical;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}

legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.5rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  min-height: 44px;
  min-width: 44px;
  padding: 0 1rem;
  font: inherit;
  font-size: 1rem;
  color: var(--page-text);
  background: var(--secondary-bg);
  border: 1px solid var(--hint);
  border-radius: 22px;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  color: var(--button-text);
  background: var(--button);
  border-color: var(--button);
}

.type-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.type-controls input {
  flex: 1 1 12rem;
}

.result {
  font-weight: 600;
  min-height: 1.5rem;
  margin: -0.5rem 0 1rem;
}

button {
  min-height: 44px;
  padding: 0 1rem;
  font: inherit;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
}

.primary {
  color: var(--button-text);
  background: var(--button);
  border: 1px solid var(--button);
}

.secondary {
  color: var(--page-text);
  background: var(--secondary-bg);
  border: 1px solid var(--hint);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.actions button {
  flex: 1 1 10rem;
}

/* The fallback submit button. form.js hides it inside Telegram. */
.fallback {
  flex: 1 1 100%;
  width: 100%;
  color: var(--button-text);
  background: var(--button);
  border: 1px solid var(--button);
}

/* The row of time buttons that form.js puts inside #when-result. */
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

#media {
  margin-bottom: 1rem;
}

:focus-visible {
  outline: 3px solid var(--button);
  outline-offset: 2px;
}

/* The list screen (web/static/list.html). Each row is one large button. */
#list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  width: 100%;
  min-height: 56px;
  padding: 0.75rem 1rem;
  text-align: left;
  font: inherit;
  font-size: 1rem;
  color: var(--page-text);
  background: var(--secondary-bg);
  border: 1px solid var(--hint);
  border-radius: 8px;
  cursor: pointer;
}

.list-caption {
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.list-meta {
  display: block;
  color: var(--hint);
}

.list-waiting {
  display: block;
  font-weight: 600;
}

/* The photos and videos section of the post form (web/static/form.js). */
#media h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}

#media-add {
  width: 100%;
}

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0;
}

#media-list:empty {
  display: none;
}

.media-tile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--secondary-bg);
  border: 1px solid var(--hint);
  border-radius: 8px;
}

.media-tile.rejected {
  border-color: var(--problem);
}

.media-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--page-bg);
  border-radius: 6px;
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-status {
  margin: 0;
  overflow-wrap: anywhere;
}

.media-tile.rejected .media-status {
  color: var(--problem);
  font-weight: 600;
}

.media-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.media-buttons button {
  flex: 1 1 5rem;
}
