:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #dbe2ef;
  --accent: #1d4ed8;
  --pass: #2e7d32;
  --warn: #ef6c00;
  --fail: #c62828;
  --shadow: 0 3px 14px rgba(22, 34, 67, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.42;
}

.app-header {
  max-width: 1160px;
  margin: 0.85rem auto 0;
  padding: 0.9rem 1rem;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
}

h1 {
  margin: 0;
  font-size: 1.34rem;
  line-height: 1.2;
}

h2 {
  margin: 0 0 0.62rem;
  font-size: 1.02rem;
  line-height: 1.25;
}

h3 {
  margin: 0.8rem 0 0.45rem;
  font-size: 0.92rem;
  line-height: 1.25;
}

.privacy-note {
  margin-top: 0.72rem;
  padding: 0.58rem 0.8rem;
  border-left: 6px solid var(--accent);
  background: #e8f0ff;
  border-radius: 8px;
  font-size: 0.88rem;
}

.muted {
  color: var(--muted);
}

.layout {
  max-width: 1160px;
  margin: 0 auto 1.15rem;
  padding: 0 1rem;
  display: grid;
  gap: 0.68rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.82rem;
  box-shadow: var(--shadow);
}

.workspace-panel {
  padding: 0.92rem;
}

.editor-preview-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.03fr) minmax(340px, 0.97fr);
  gap: 0.72rem;
  align-items: start;
}

.editor-pane,
.preview-pane {
  min-width: 0;
}

.preview-pane {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

.preview-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 0.36rem;
}

.preview-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 1fr));
  gap: 0.34rem;
}

.preview-control-btn {
  margin-top: 0;
  font-size: 0.8rem;
  padding: 0.4rem 0.54rem;
  min-height: 31px;
}

.preview-control-btn.is-active {
  background: #dce7ff;
  color: #1b3f96;
  box-shadow: inset 0 0 0 1px #b7ccff;
}

.preview-field {
  margin: 0.22rem 0 0;
  font-size: 0.79rem;
  color: var(--muted);
}

.preview-base-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.43rem 0.56rem;
  font-size: 0.82rem;
  background: #fff;
}

.preview-meta {
  margin: 0;
  font-size: 0.78rem;
}

.preview-state {
  border: 1px dashed #b8c4db;
  border-radius: 10px;
  padding: 0.45rem 0.62rem;
  background: #f8fbff;
  font-size: 0.79rem;
}

.preview-state.error {
  border-color: #e0a4a0;
  background: #fff5f5;
  color: var(--fail);
}

.preview-frame-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #eef2f7;
  padding: 0.4rem;
  overflow: auto;
}

.preview-notes {
  margin: 0;
  padding-left: 1rem;
  color: #455265;
  font-size: 0.78rem;
}

.preview-notes li {
  margin: 0.1rem 0;
}

.email-preview-frame {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: #f3f4f6;
}

.preview-frame-wrap[data-viewport="desktop"] .email-preview-frame {
  max-width: 700px;
  height: 640px;
  margin: 0 auto;
}

.preview-frame-wrap[data-viewport="mobile"] .email-preview-frame {
  max-width: 375px;
  height: 600px;
  margin: 0 auto;
}

.preview-frame-wrap.full .email-preview-frame {
  height: 820px;
}

.hidden {
  display: none;
}

.drop-zone {
  border: 2px dashed #b8c4db;
  border-radius: 10px;
  padding: 0.78rem;
  text-align: center;
  cursor: pointer;
  background: #f8fbff;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.drop-zone.active {
  border-color: var(--accent);
  background: #edf3ff;
  box-shadow: inset 0 0 0 1px #b7ccff;
}

.upload-status {
  margin: 0.36rem 0 0.28rem;
  font-size: 0.78rem;
  color: #4f5d70;
  min-height: 1.1rem;
  font-weight: 500;
}

.html-editor {
  min-height: 420px;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.usage-hints {
  margin: 0.45rem 0 0;
  padding-left: 1rem;
  font-size: 0.78rem;
  color: #455265;
}

.usage-hints li {
  margin: 0.12rem 0;
}

.empty-hint {
  margin: 0;
  font-size: 0.79rem;
}

.upload-status--success {
  color: var(--pass);
}

.upload-status--error {
  color: var(--fail);
}

.upload-status--info {
  color: #4f5d70;
}

textarea {
  width: 100%;
  resize: vertical;
  margin-top: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.64rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.82rem;
}

button {
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.68rem;
  cursor: pointer;
  font-size: 0.82rem;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.primary-btn {
  margin-top: 0.48rem;
  background: var(--accent);
  color: #fff;
  min-height: 34px;
}

.secondary-btn {
  margin-top: 0.35rem;
  background: #e8ebf4;
  color: #222;
  min-height: 32px;
}

.results-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 0.68rem;
  align-items: stretch;
  margin-top: 0;
}

.results-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.report-panel {
  grid-column: 1 / -1;
}

.summary-row {
  display: grid;
  gap: 0.55rem;
}

.status-pill {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-weight: 600;
}

.status-pass {
  background: #e7f6ea;
  color: var(--pass);
}

.status-warning {
  background: #fff2e8;
  color: var(--warn);
}

.status-fail {
  background: #fdebea;
  color: var(--fail);
}

.issue-card {
  border: 1px solid var(--border);
  border-left: 5px solid #4b5563;
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.7rem;
  background: #fcfdff;
}

.issue-client {
  font-size: 0.8rem;
  color: var(--muted);
}

.diagnostics-panel,
.issues-panel {
  min-height: 150px;
  flex: 1;
}

.report-output {
  margin: 0;
  white-space: pre-wrap;
  max-height: 220px;
  min-height: 170px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1020;
  color: #d9e3ff;
  padding: 0.8rem;
  font-size: 0.82rem;
}

.app-footer {
  max-width: 1160px;
  margin: 0.2rem auto 1rem;
  padding: 0 1rem;
  color: #546378;
  font-size: 0.76rem;
}

.app-footer p {
  margin: 0;
}

@media (max-width: 640px) {
  .brand-wrap {
    align-items: flex-start;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
  }

  .app-header {
    padding-top: 0.78rem;
  }

  .layout {
    gap: 0.6rem;
  }

  .preview-toolbar {
    grid-template-columns: 1fr;
  }

  .preview-controls {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .editor-preview-grid {
    grid-template-columns: 1fr;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .report-panel {
    grid-column: auto;
  }

  .html-editor {
    min-height: 320px;
  }
}

@media (max-width: 960px) {
  .editor-preview-grid {
    grid-template-columns: 1fr;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .report-panel {
    grid-column: auto;
  }

  .preview-frame-wrap[data-viewport="desktop"] .email-preview-frame {
    height: 560px;
  }
}
