:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --accent: #16a34a;
  --accent-hover: #128a3e;
  --border: #d8dbe0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #1a1d24;
    --text: #f0f0f0;
    --muted: #9aa0aa;
    --border: #2c303a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 3rem 1rem;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}

main:has(#app:not([hidden])) {
  max-width: 1180px;
  padding: 2.5rem;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 0.25rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 480px) 1fr;
  align-items: start;
  gap: 2.5rem;
}

.panel-main {
  min-width: 0;
}

.panel-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 2rem;
}

@media (max-width: 900px) {
  main:has(#app:not([hidden])) {
    max-width: 640px;
    padding: 1.5rem;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .panel-side {
    position: static;
  }
}

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

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  padding: 1rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.dropzone.dragover {
  border-color: var(--accent);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

#dropzone-text {
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  background: transparent;
  color: var(--text);
}

select {
  color-scheme: light dark;
}

button {
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

#status {
  min-height: 1.2rem;
  font-size: 0.9rem;
  text-align: center;
  margin: 1rem 0 0;
}

#status.error { color: #dc2626; }
#status.success { color: var(--accent); }

.error { color: #dc2626; font-size: 0.85rem; min-height: 1.1rem; }

#auth-form {
  flex-direction: row;
}

#auth-form input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
}

#auth-form button {
  width: auto;
  padding: 0.6rem 1.2rem;
}

.url-add-row {
  display: flex;
  gap: 0.5rem;
}

.url-add-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

.url-add-row button {
  width: auto;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

#file-list,
#message-image-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#file-list li,
#message-image-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}

#file-list img,
#message-image-list img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

#file-list .file-name,
#message-image-list .file-name {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-caption {
  width: 100%;
  font-size: 0.78rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
}

#file-list .file-actions,
#message-image-list .file-actions {
  display: flex;
  gap: 0.25rem;
}

#file-list button,
#message-image-list button {
  width: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

#file-list button:hover:not(:disabled) {
  background: var(--border);
}

#progress-bar,
#message-progress-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

#progress-fill,
#message-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.field-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: -0.5rem 0 0;
}

#message-phone {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  background: transparent;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.tab-btn:hover:not(:disabled) {
  background: transparent;
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel[hidden] {
  display: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.mode-toggle {
  display: flex;
  gap: 1.5rem;
}

.mode-toggle label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

#schedule-fields,
#message-schedule-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}

#schedule-fields[hidden],
#once-fields[hidden],
#weekly-fields[hidden],
#message-schedule-fields[hidden],
#message-once-fields[hidden],
#message-weekly-fields[hidden] {
  display: none;
}

#schedule-datetime,
#schedule-time,
#message-schedule-datetime,
#message-schedule-time {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}

.weekday-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.weekday-picker label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

#scheduled-section,
#message-scheduled-section,
#posted-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem 1.25rem;
  background: var(--bg);
}

#scheduled-section h2,
#message-scheduled-section h2,
#posted-section h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

#scheduled-list,
#message-scheduled-list,
#posted-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#scheduled-list li,
#message-scheduled-list li,
#posted-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}

#scheduled-list img,
#message-scheduled-list img,
#posted-list img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

#scheduled-list .scheduled-info,
#message-scheduled-list .scheduled-info,
#posted-list .scheduled-info {
  flex: 1;
  font-size: 0.8rem;
  color: var(--muted);
}

#scheduled-list .scheduled-info strong,
#message-scheduled-list .scheduled-info strong,
#posted-list .scheduled-info strong {
  display: block;
  color: var(--text);
  font-size: 0.85rem;
}

#scheduled-list button,
#message-scheduled-list button {
  width: auto;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  color: #dc2626;
}

#posted-list button {
  width: auto;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

#scheduled-empty,
#message-scheduled-empty,
#posted-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

#file-list img,
#scheduled-list img,
#message-image-list img,
#message-scheduled-list img,
#posted-list img {
  cursor: zoom-in;
}

#file-list li {
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#file-list li[draggable="true"] {
  cursor: grab;
}

#file-list li.dragging {
  opacity: 0.4;
}

#file-list li.drag-over {
  border-color: var(--accent);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.overlay[hidden] {
  display: none;
}

#lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}

.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 320px;
  width: 100%;
}

.modal-box p {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.submit-row {
  display: flex;
  gap: 0.6rem;
}

.submit-row button {
  flex: 1;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
}

.modal-actions button {
  flex: 1;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}
