:root {
  color-scheme: light;
  --bg: #0b141a;
  --card: #ffffff;
  --muted: #64748b;
  --accent: #25d366;
  --accent-dark: #128c7e;
  --border: rgba(148, 163, 184, 0.3);
  --shadow: 0 30px 60px rgba(8, 15, 26, 0.25);
  --radius-lg: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2933 0%, #0b141a 55%, #05080a 100%);
  padding: clamp(20px, 4vw, 56px);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-shell {
  width: min(1080px, 100%);
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.app-header {
  padding: clamp(24px, 3vw, 32px) clamp(28px, 4vw, 40px) 0 clamp(28px, 4vw, 40px);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-icon {
  height: 56px;
  width: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  box-shadow: 0 16px 30px rgba(37, 211, 102, 0.35);
}

.header-icon svg {
  height: 30px;
  width: 30px;
  fill: #f8fafc;
}

.header-title h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  color: #0f172a;
}

.header-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 2.2vw, 24px);
  padding: 0 clamp(28px, 4vw, 40px) clamp(28px, 4vw, 40px);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: clamp(20px, 3vw, 28px);
  background: #f8fafc;
  position: relative;
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 600;
  color: #1f2937;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field-group:last-of-type {
  margin-bottom: 0;
}

label {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.95rem;
}

input[type="text"],
input[type="datetime-local"],
select,
textarea {
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 12px 14px;
  font-size: 0.95rem;
  line-height: 1.45;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #ffffff;
  color: #0f172a;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(37, 211, 102, 0.6);
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.15);
}

textarea {
  min-height: 120px;
  max-height: 320px;
}

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

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

.field-row .field-group {
  flex: 1 1 180px;
}

.counter {
  margin-top: -4px;
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
}

.schedule-fields {
  display: none;
  animation: fade 0.2s ease;
}

.schedule-fields.visible {
  display: flex;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.preview-wrapper {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-device {
  flex: 1;
  background: linear-gradient(180deg, #101a23 0%, #15232f 100%);
  border-radius: 28px;
  padding: 24px 18px 28px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-statusbar,
.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(248, 250, 252, 0.6);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.chat-meta {
  align-self: center;
  background: rgba(15, 23, 42, 0.35);
  color: rgba(248, 250, 252, 0.75);
  font-size: 0.72rem;
  padding: 6px 12px;
  border-radius: 999px;
}

.chat-bubble {
  max-width: 100%;
  background: #1f2b37;
  padding: 14px 16px;
  border-radius: 18px 18px 4px 18px;
  color: #e2e8f0;
  font-size: 0.95rem;
  line-height: 1.5;
  box-shadow: 0 18px 35px rgba(8, 15, 26, 0.32);
  position: relative;
}

.chat-bubble strong {
  color: #f8fafc;
}

#previewMessage {
  white-space: pre-line;
}

.preview-token {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  margin: 0 1px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.22);
  color: #f8fafc;
  font-weight: 600;
  font-size: 0.92em;
  letter-spacing: 0.01em;
}

.chat-media {
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 12px;
  display: none;
}

.chat-media.visible {
  display: block;
}

.chat-media img {
  width: 100%;
  display: block;
  object-fit: cover;
  max-height: 160px;
}

.chat-button {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(37, 211, 102, 0.16);
  color: #bbf7d0;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-button .preview-token {
  background: rgba(15, 118, 110, 0.45);
  color: #ecfdf5;
}

.actions {
  border-top: 1px solid var(--border);
  padding: clamp(20px, 3vw, 28px) clamp(28px, 4vw, 40px);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: rgba(248, 250, 252, 0.9);
}

button {
  border: none;
  border-radius: 14px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 12px 24px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#cancel {
  background: transparent;
  color: #475569;
}

#cancel:hover {
  transform: translateY(-1px);
  color: #1f2937;
}

#done {
  background: var(--accent);
  color: #052e16;
  box-shadow: 0 14px 30px rgba(37, 211, 102, 0.32);
}

#done:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

#done:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 38px rgba(37, 211, 102, 0.42);
}

.status-message {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease-out;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.status-message.success {
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.status-message.error {
  background-color: #fbe9e7;
  color: #c62828;
  border: 1px solid #ffab91;
}

.status-message .icon {
  font-size: 18px;
  font-weight: bold;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (max-width: 960px) {
  body {
    padding: clamp(16px, 4vw, 28px);
  }

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

  .preview-wrapper {
    min-height: 420px;
  }
}

@media (max-width: 720px) {
  .app-header {
    padding: 24px 24px 0;
  }

  .panels {
    padding: 0 24px 24px;
  }

  .actions {
    padding: 20px 24px;
  }
}
