:root {
  /* Base palette */
  --bg: #f5f6fa;
  --bg-soft: #eef1f7;
  --panel-bg: #ffffff;

  /* Text */
  --text: #1b2130;
  --text-sub: #5a6273;
  --text-faint: #8b93a3;

  /* Lines & accents */
  --border: #e7e9f0;
  --border-strong: #d7dbe6;
  --assistant: #2563eb;
  --assistant-strong: #1d4ed8;
  --assistant-soft: #eef4ff;
  --generate: #7c3aed;
  --generate-strong: #6d28d9;
  --generate-soft: #f5effe;

  /* Shape */
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(20, 24, 35, 0.04);
  --shadow: 0 10px 30px -12px rgba(20, 24, 35, 0.14);
  --shadow-hover: 0 18px 40px -16px rgba(20, 24, 35, 0.22);

  /* Fonts */
  --font-sans: "Inter", "Noto Sans JP", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Meiryo", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background:
    radial-gradient(1100px 500px at 50% -120px, #eaf0ff 0%, rgba(234, 240, 255, 0) 70%),
    var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Header */
.app-header {
  background: linear-gradient(125deg, #1e293b 0%, #273449 55%, #3b2f6b 100%);
  color: #fff;
  padding: 40px 20px 34px;
}
.header-inner { max-width: 1120px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 14px; }
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--assistant), var(--generate));
  box-shadow: 0 8px 20px -6px rgba(124, 58, 237, 0.55);
  font-size: 24px;
  font-weight: 700;
}
.app-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.header-sub {
  margin: 14px 0 0;
  color: #c3ccdb;
  font-size: 15px;
  max-width: 640px;
}

/* Layout */
.layout {
  max-width: 1120px;
  margin: -16px auto 32px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
}

/* Panels */
.panel {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.panel:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.panel-assistant { border-top: 3px solid var(--assistant); }
.panel-generate { border-top: 3px solid var(--generate); }

.panel-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--assistant-soft);
  color: var(--assistant);
  margin-bottom: 16px;
}
.badge-generate { background: var(--generate-soft); color: var(--generate); }

.panel-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.panel-desc {
  margin: 0 0 26px;
  color: var(--text-sub);
  font-size: 14.5px;
}

/* Fields */
.field { margin-bottom: 22px; }
.field-row { display: flex; gap: 18px; }
.field-row .field { flex: 1; min-width: 0; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 9px;
  color: var(--text);
}

.select, .textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.6;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.select {
  min-height: 46px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a6273' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}
.textarea { resize: vertical; min-height: 96px; }
.select:hover, .textarea:hover { border-color: #c2c8d6; }
.select:focus, .textarea:focus {
  outline: none;
  border-color: var(--assistant);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

/* Upload box */
.upload-box {
  border: 2px dashed #ccd1dd;
  border-radius: var(--radius);
  padding: 30px 16px;
  text-align: center;
  cursor: pointer;
  background: #fafbfe;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.upload-box:hover { border-color: var(--assistant); background: var(--assistant-soft); }
.upload-box.is-active {
  border-style: solid;
  border-color: var(--assistant);
  background: var(--assistant-soft);
}
.upload-icon { font-size: 32px; line-height: 1; }
.upload-text { margin: 10px 0 3px; font-size: 14.5px; font-weight: 600; }
.upload-hint { margin: 0; font-size: 12.5px; color: var(--text-faint); }

/* Buttons */
.btn {
  width: 100%;
  min-height: 50px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 15.5px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); opacity: 0.92; }
.btn:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.45); outline-offset: 2px; }
.btn:disabled { cursor: default; opacity: 0.6; transform: none; box-shadow: none; }
.btn-assistant {
  background: linear-gradient(135deg, var(--assistant), var(--assistant-strong));
  box-shadow: 0 12px 24px -10px rgba(37, 99, 235, 0.65);
}
.btn-assistant:hover { box-shadow: 0 16px 30px -10px rgba(37, 99, 235, 0.7); }
.btn-generate {
  background: linear-gradient(135deg, var(--generate), var(--generate-strong));
  box-shadow: 0 12px 24px -10px rgba(124, 58, 237, 0.6);
}
.btn-generate:hover { box-shadow: 0 16px 30px -10px rgba(124, 58, 237, 0.68); }

/* Hints & notices */
.note-hint {
  margin: 11px 2px 0;
  font-size: 12.5px;
  color: var(--text-faint);
}
.powered-hint {
  margin: 10px 2px 0;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: right;
}
.info-banner {
  background: #fff8ef;
  border: 1px solid #f6dcb8;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13.5px;
  color: #92400e;
  line-height: 1.65;
  margin-bottom: 24px;
}
.generate-notice {
  margin-top: 16px;
  background: #fff8ef;
  border: 1px solid #f6dcb8;
  border-radius: var(--radius);
  padding: 15px 16px;
  font-size: 13.5px;
  color: #92400e;
  line-height: 1.65;
}

/* Result box */
.result-field { margin-top: 24px; }
.result-box {
  background: var(--assistant-soft);
  border: 1px solid #d6e2ff;
  border-radius: var(--radius);
  padding: 18px 20px;
  font-size: 14.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  color: #1e3a8a;
}
.result-label { font-weight: 700; }

/* Result states */
.result-ok { background: var(--assistant-soft); border-color: #d6e2ff; color: #1e3a8a; }
.result-loading { background: #f3f5f9; border-color: var(--border); color: var(--text-sub); }
.result-warn { background: #fffbeb; border-color: #fce29a; color: #92400e; }
.result-error { background: #fef2f2; border-color: #f7c5c5; color: #b91c1c; }

/* Preview grid */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.preview-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.preview-thumb {
  height: 156px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, #f2f1fc, #f2f1fc 12px, #e9e7f8 12px, #e9e7f8 24px);
  color: var(--generate);
  font-size: 13px;
  font-weight: 700;
}
.preview-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 4px;
}
.preview-page { font-weight: 700; font-size: 14px; }
.preview-panels {
  font-size: 12px;
  font-weight: 600;
  color: var(--generate);
  background: var(--generate-soft);
  padding: 3px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.preview-note {
  margin: 0;
  padding: 2px 14px 16px;
  font-size: 12.5px;
  color: var(--text-sub);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 28px 20px 48px;
  color: var(--text-faint);
  font-size: 12.5px;
}

/* Tablet */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; margin-top: -8px; }
}

/* Mobile */
@media (max-width: 560px) {
  body { font-size: 15.5px; }
  .app-header { padding: 30px 16px 26px; }
  .app-header h1 { font-size: 22px; }
  .header-sub { font-size: 14px; }
  .logo-mark { width: 44px; height: 44px; font-size: 22px; }
  .layout { margin: 0 auto 24px; padding: 0 14px; gap: 18px; }
  .panel { padding: 22px; border-radius: var(--radius); }
  .panel-title { font-size: 20px; }
  .field-row { flex-direction: column; gap: 0; }
  .preview-grid { grid-template-columns: 1fr; }
}

/* Motion preferences */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .panel:hover, .preview-card:hover, .btn:hover { transform: none; }
}
