:root {
  color-scheme: light;
  --bg: #f7f3ee;
  --panel: #fff7ee;
  --panel-strong: #f2e6d8;
  --ink: #1b1b1b;
  --muted: #6f6457;
  --accent: #1f8a4c;
  --accent-dark: #17683a;
  --outline: #e3d5c4;
  --shadow: 0 14px 40px rgba(37, 26, 14, 0.18);
  --preview-height: min(60vh, 540px);
  --preview-min-height: 320px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #fff2e1, #f4efe8 42%, #efe7dc 100%);
  color: var(--ink);
  min-height: 100vh;
}

a {
  color: var(--accent-dark);
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fadeIn 0.5s ease;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--outline);
  border-radius: 18px;
  padding: 18px 22px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: conic-gradient(from 180deg, #b6e2c7, #6cc08c, #1f8a4c, #b6e2c7);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.65);
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

.brand-copy {
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
  max-width: 580px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.topnav a {
  text-decoration: none;
  font-weight: 700;
  color: var(--ink);
}

.topnav a:hover {
  color: var(--accent-dark);
}

input[type="file"] {
  display: none;
}

#g_id_onload {
  display: none;
}

.auth-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-button {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid var(--outline);
  background: #fffaf5;
  box-shadow: 0 10px 18px rgba(44, 24, 6, 0.08);
}

.auth-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.auth-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.auth-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
}

.auth-email {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.1;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signout-btn {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
  background: #fff1ee;
  border-color: rgba(138, 31, 31, 0.2);
  color: #8a1f1f;
  box-shadow: none;
}

.signout-btn:hover {
  background: #ffe6e1;
  box-shadow: none;
}

.auth-hint {
  font-size: 11px;
  color: var(--muted);
  max-width: 240px;
}

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

.article-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fadeIn 0.5s ease;
}

.article-card {
  background: var(--panel);
  border: 1px solid var(--outline);
  border-radius: 24px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.article-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--outline);
}

.article-topbar a {
  font-weight: 700;
  text-decoration: none;
}

.article-hero,
.article-section {
  padding: 16px 0;
}

.article-hero p,
.article-section p {
  margin-top: 12px;
  font-size: 16px;
  line-height: 1.7;
  color: #3b332b;
}

.article-section h2 {
  font-size: 22px;
  line-height: 1.2;
}

.article-section + .article-section {
  border-top: 1px solid rgba(227, 213, 196, 0.7);
}

.article-list {
  margin-top: 14px;
  padding-left: 20px;
  color: #3b332b;
}

.article-list li + li {
  margin-top: 10px;
}

.article-steps {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 16px;
}

.article-step {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--outline);
  background: #fffaf5;
}

.article-step h3 {
  font-size: 18px;
  line-height: 1.3;
}

.article-step p {
  margin-top: 8px;
}

.article-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.article-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fffaf5;
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(31, 138, 76, 0.12);
}

.article-button.secondary {
  background: #fffaf3;
  color: var(--ink);
  border-color: var(--outline);
  box-shadow: none;
}

.guide-list {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.guide-card {
  display: block;
  padding: 12px 0;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.guide-card + .guide-card {
  border-top: 1px solid rgba(227, 213, 196, 0.7);
}

.guide-card-kicker {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.guide-card-title {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
}

.guide-card-copy {
  display: block;
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.6;
  color: #3b332b;
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.9fr);
  gap: 22px;
}

.canvas-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: var(--preview-height);
  min-height: var(--preview-min-height);
  border-radius: 22px;
  background: linear-gradient(135deg, #fbf4ea, #efe2d1);
  border: 1px solid var(--outline);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.canvas-wrap.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 138, 76, 0.15), var(--shadow);
}

.corner-button {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  pointer-events: auto;
  transition: transform 0.2s ease;
}

.corner-button svg {
  width: 20px;
  height: 20px;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.canvas-wrap:hover .corner-button {
  transform: translateY(-2px);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  pointer-events: auto;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(247, 243, 238, 0.78);
  backdrop-filter: blur(6px);
  z-index: 2;
}

.loading-card {
  width: min(360px, 100%);
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(255, 250, 243, 0.96);
  border: 1px solid rgba(31, 138, 76, 0.14);
  box-shadow: 0 18px 32px rgba(37, 26, 14, 0.16);
}

.loading-title {
  font-size: 18px;
  font-weight: 700;
}

.loading-subtitle {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.loading-progress {
  margin-top: 14px;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #efe7dc;
  border: 1px solid var(--outline);
  overflow: hidden;
}

.loading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7fd6a4, #1f8a4c);
  transition: width 0.15s ease;
}

.loading-progress-bar.indeterminate {
  width: 40%;
  animation: loadingSlide 1s ease-in-out infinite;
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
}

.empty-subtitle {
  font-size: 14px;
  margin-top: 6px;
}

.canvas-hint {
  font-size: 13px;
  color: var(--accent);
}

.side-panel {
  background: var(--panel);
  border-radius: 22px;
  border: 1px solid var(--outline);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow);
  height: var(--preview-height);
  min-height: var(--preview-min-height);
  overflow: auto;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
}

button {
  border: 1px solid var(--outline);
  background: #fffaf3;
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(44, 24, 6, 0.12);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary {
  background: var(--accent);
  color: #fffaf5;
  border-color: transparent;
}

.ghost {
  background: transparent;
}

.region-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.region-item {
  border: 1px solid var(--outline);
  border-radius: 14px;
  padding: 10px;
  background: #fffaf5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.region-item.is-collapsed {
  padding-bottom: 8px;
}

.region-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.region-item.is-collapsed .region-body {
  display: none;
}

.region-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(31, 138, 76, 0.2);
}

.region-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.region-name {
  font-weight: 700;
  font-size: 14px;
}

.region-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-group input {
  border: 1px solid var(--outline);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
}

.input-group input.color-input {
  width: 100%;
  max-width: 56px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  background: #fffaf3;
}

.input-group input.color-input::-webkit-color-swatch-wrapper {
  padding: 4px;
}

.input-group input.color-input::-webkit-color-swatch {
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

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

.color-row .input-group {
  min-width: 0;
  width: 72px;
  align-items: center;
}

.color-row .input-group label {
  text-align: center;
  width: 100%;
}

.input-group select {
  border: 1px solid var(--outline);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
  background: #fffdf9;
}

.region-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fffdf9;
  border: 1px solid var(--outline);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-btn:hover {
  background: #f4efe8;
}

.icon-btn.danger {
  color: #8a1f1f;
  border-color: rgba(138, 31, 31, 0.3);
}

.input-group {
  min-width: 0;
}

.toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

.toggle.switch {
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--outline);
  background: #fffaf5;
  box-shadow: 0 10px 18px rgba(44, 24, 6, 0.08);
  position: relative;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #efe7dc;
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: background 0.2s ease, border-color 0.2s ease;
  flex: 0 0 auto;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fffdf9;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 6px 10px rgba(44, 24, 6, 0.15);
  transition: transform 0.2s ease;
}

.switch-label {
  font-size: 13px;
}

.switch input:checked + .switch-track {
  background: rgba(31, 138, 76, 0.22);
  border-color: rgba(31, 138, 76, 0.45);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
}

.lower-third-toggle {
  margin-top: 2px;
  font-size: 13px;
}

.region-lower-third {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(227, 213, 196, 0.8);
}

.region-lower-third.is-enabled {
  display: grid;
}

.region-span-2 {
  grid-column: 1 / -1;
}

.font-select {
  position: relative;
}

.font-select-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: #fffdf9;
  text-align: left;
}

.font-select-button-label {
  font-size: 16px;
  line-height: 1.2;
}

.font-select-button-caret {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.font-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 5;
  display: none;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid var(--outline);
  background: rgba(255, 251, 245, 0.98);
  box-shadow: 0 18px 30px rgba(37, 26, 14, 0.16);
  backdrop-filter: blur(8px);
}

.font-select.is-open .font-select-menu {
  display: grid;
  gap: 6px;
}

.font-menu-item {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  box-shadow: none;
}

.font-menu-item:hover {
  background: #fff5e8;
  box-shadow: none;
}

.font-menu-item.is-selected {
  border-color: rgba(31, 138, 76, 0.28);
  background: #fff9ef;
}

.font-menu-item-label {
  font-size: 18px;
  line-height: 1.2;
}

.muted {
  font-size: 12px;
  color: var(--muted);
}

.actions {
  margin-top: auto;
}

.progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #efe7dc;
  border: 1px solid var(--outline);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7fd6a4, #1f8a4c);
  transition: width 0.15s ease;
}

.hidden {
  display: none;
}

.status {
  min-height: 18px;
  font-size: 13px;
  color: var(--muted);
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f0fbf5;
  border: 1px solid rgba(31, 138, 76, 0.25);
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 20px rgba(31, 138, 76, 0.12);
}

.download-link:empty {
  display: none;
}

.seo-content {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.seo-card,
.faq-card {
  background: var(--panel);
  border-radius: 22px;
  border: 1px solid var(--outline);
  padding: 22px;
  box-shadow: var(--shadow);
}

.seo-card h2,
.faq-card h2 {
  font-size: 18px;
  line-height: 1.2;
}

.seo-card p,
.faq-item p {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.65;
  color: #3b332b;
}

.seo-list {
  margin-top: 12px;
  padding-left: 18px;
  color: #3b332b;
}

.seo-list li + li {
  margin-top: 8px;
}

.faq-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.faq-item h3 {
  font-size: 16px;
  line-height: 1.35;
}

@media (max-width: 980px) {
  .main {
    grid-template-columns: 1fr;
  }

  .seo-grid,
  .faq-list {
    grid-template-columns: 1fr;
  }

  .article-shell {
    padding: 18px;
  }

  .topnav {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }

  .side-panel {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes loadingSlide {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(320%);
  }
}
