/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; }
[hidden] { display: none !important; }

:root {
  --red:         #B91C1C;
  --red-dark:    #991B1B;
  --red-light:   #FEE2E2;
  --red-pale:    #FFF5F5;

  --fg:          #1A1A1A;
  --fg-muted:    #6B7280;
  --fg-faint:    #9CA3AF;

  --bg:          #F8F8F8;
  --surface:     #FFFFFF;
  --border:      #E5E7EB;
  --border-focus:#B91C1C;

  --sidebar-bg:  #FFFFFF;
  --sidebar-w:   210px;
  --right-w:     220px;

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --shadow-md:   0 2px 8px rgba(0,0,0,.08), 0 4px 20px rgba(0,0,0,.06);

  --header-h:    56px;
}

html { height: 100%; }

body {
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--fg);
  min-height: 100%;
}

/* ================================================================
   HEADER
================================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--red);
  color: #fff;
  height: var(--header-h);
  box-shadow: 0 2px 8px rgba(185,28,28,.3);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.logo-icon { flex-shrink: 0; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  color: rgba(255,255,255,.88);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.nav-link:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
}

.header-actions { margin-left: auto; flex-shrink: 0; }

.btn-login {
  display: inline-block;
  padding: 7px 16px;
  border: 1.5px solid rgba(255,255,255,.8);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.btn-login:hover {
  background: #fff;
  color: var(--red);
}

.btn-login--mobile { display: none; }

/* hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: .2s;
}

/* ================================================================
   MOBILE NAV
================================================================ */
.mobile-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 199;
}

.mobile-nav {
  position: fixed;
  top: 0;
  left: -280px;
  width: 268px;
  height: 100%;
  background: var(--surface);
  box-shadow: 4px 0 20px rgba(0,0,0,.15);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 0;
  transition: left .25s ease;
  overflow-y: auto;
}

.mobile-nav.is-open { left: 0; }
.mobile-nav-backdrop.is-open { display: block; }

.mnav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--red);
  color: #fff;
  flex-shrink: 0;
}

.mnav-logo {
  font-size: 15px;
  font-weight: 700;
}

.mobile-nav-close {
  background: none;
  border: none;
  font-size: 18px;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
}
.mobile-nav-close:hover { color: #fff; }

.mnav-section { padding: 8px 0; }

.mnav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding: 8px 20px 4px;
}

.mnav-link {
  display: block;
  padding: 9px 20px;
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  transition: background .1s;
}
.mnav-link:hover { background: var(--red-pale); color: var(--red); }
.mnav-link--active { color: var(--red); font-weight: 600; }
.mnav-link--primary {
  color: var(--red);
  font-weight: 700;
  padding: 12px 20px;
}

.mnav-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

/* ================================================================
   LAYOUT  (3-column grid)
================================================================ */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--right-w);
  gap: 20px;
  align-items: start;
}

/* ================================================================
   LEFT SIDEBAR
================================================================ */
.sidebar--left {
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 0;
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(185,28,28,.35) transparent;
}
.sidebar--left::-webkit-scrollbar { width: 4px; }
.sidebar--left::-webkit-scrollbar-track { background: transparent; }
.sidebar--left::-webkit-scrollbar-thumb {
  background: rgba(185,28,28,.35);
  border-radius: 99px;
}
.sidebar--left::-webkit-scrollbar-thumb:hover { background: rgba(185,28,28,.6); }

.sidebar-group { padding: 8px 0; }
.sidebar-group + .sidebar-group { border-top: 1px solid var(--border); }

.sidebar-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding: 8px 16px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 13px;
  transition: background .12s, color .12s;
  border-radius: 0;
}
.sidebar-link:hover { background: var(--red-pale); color: var(--red); }
.sidebar-link--active {
  background: var(--red-light);
  color: var(--red);
  font-weight: 600;
  border-right: 3px solid var(--red);
}

.sidebar-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

/* ================================================================
   MAIN CONTENT
================================================================ */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.page-heading { padding-bottom: 4px; }

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.3;
}

.page-subtitle {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 4px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
}

/* ── Input type tabs ── */
.input-type-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.tab-btn svg { width: 20px; height: 20px; }
.tab-btn:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-pale);
}
.tab-btn--active {
  border-color: var(--red) !important;
  color: var(--red) !important;
  background: var(--red-light) !important;
  font-weight: 600;
}
.tab-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* ── URL Input ── */
.input-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
}

.input-wrapper { position: relative; }

.url-input {
  width: 100%;
  padding: 10px 38px 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--fg);
  background: var(--bg);
  outline: none;
  transition: border-color .15s, background .15s;
}
.url-input::placeholder { color: var(--fg-faint); }
.url-input:focus {
  border-color: var(--border-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(185,28,28,.1);
}
.url-input--error {
  border-color: var(--red) !important;
  background: #FFF1F1 !important;
  box-shadow: 0 0 0 3px rgba(185,28,28,.15) !important;
}

.clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  color: var(--fg-faint);
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  transition: color .1s, background .1s;
}
.clear-btn:hover { color: var(--fg); background: var(--border); }

.error-msg {
  font-size: 12px;
  color: var(--red);
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .08s, opacity .15s;
  text-decoration: none;
}
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; }

.btn-full { width: 100%; }

/* ── Color swatches ── */
.customize-block { display: flex; flex-direction: column; gap: 8px; }

.customize-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
}

.color-swatches {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
  outline: none;
  flex-shrink: 0;
}
.swatch:hover { transform: scale(1.12); }
.swatch--active { border-color: var(--fg) !important; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--fg); }

.swatch--custom {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 2px dashed var(--border);
  cursor: pointer;
  color: var(--fg-muted);
  border-radius: 50%;
}
.swatch--custom:hover { border-color: var(--red); color: var(--red); }
.swatch--custom input[type="color"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ── QR Preview ── */
.qr-preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.qr-frame {
  width: 200px;
  height: 200px;
  position: relative;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1.5px solid var(--border);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.qr-frame.has-qr {
  background: #fff;
  border-color: var(--border);
  box-shadow: var(--shadow-md);
}

#qrcode {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#qrcode canvas, #qrcode img { display: block; }

.qr-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--fg-faint);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
  pointer-events: none;
}

.qr-url-label {
  font-size: 11px;
  color: var(--fg-faint);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* ================================================================
   RIGHT SIDEBAR
================================================================ */
.sidebar--right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
}

.right-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}

.right-panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 10px;
}

.right-panel-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color .12s;
}
.right-panel-link:hover { color: var(--red); }
.right-panel-link svg { flex-shrink: 0; color: var(--fg-faint); }
.right-panel-link:hover svg { color: var(--red); }

/* account panel */
.account-info { display: flex; flex-direction: column; gap: 6px; }
.account-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.account-key { color: var(--fg-muted); }
.account-val { font-weight: 600; color: var(--fg); }
.account-val--empty {
  color: var(--fg-faint);
  font-weight: 400;
  font-size: 12px;
}

.badge-plan {
  background: var(--red-light);
  color: var(--red);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

/* promo panel */
.right-panel--promo {
  background: var(--red);
  border-color: transparent;
  color: #fff;
}

.promo-content { display: flex; flex-direction: column; gap: 10px; }

.promo-text {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255,255,255,.9);
}
.promo-text strong { color: #fff; font-size: 15px; }

.btn-promo {
  display: inline-block;
  padding: 7px 16px;
  background: #fff;
  color: var(--red);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  transition: opacity .15s;
}
.btn-promo:hover { opacity: .88; }

/* chat button */
.btn-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--red);
  color: #fff;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
  box-shadow: var(--shadow-sm);
}
.btn-chat:hover { background: var(--red-dark); }

/* ================================================================
   FOOTER
================================================================ */
.site-footer {
  text-align: center;
  padding: 24px 20px 32px;
  font-size: 11px;
  color: var(--fg-faint);
  line-height: 1.7;
  border-top: 1px solid var(--border);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  margin: 8px 0 4px;
}

.footer-links a {
  color: var(--fg-faint);
  text-decoration: none;
  transition: color .12s;
}
.footer-links a:hover { color: var(--red); }

.footer-copy { margin-top: 4px; }

/* ================================================================
   RESPONSIVE — tablet  (≤1024px)
================================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 180px; --right-w: 190px; }
  .layout { gap: 14px; padding: 20px 16px 40px; }
  .header-nav { gap: 0; }
  .nav-link { padding: 4px 7px; font-size: 12px; }
}

/* ================================================================
   RESPONSIVE — hide sidebars  (≤860px)
================================================================ */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px 16px 40px;
  }

  .sidebar--left { display: none; }
  .sidebar--right {
    position: static;
    max-height: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  .right-panel { padding: 12px 14px; }

  .header-nav { display: none; }
  .header-actions { display: none; }
  .hamburger { display: flex; order: -1; }

  .btn-login--mobile { display: block; }
}

/* ================================================================
   RESPONSIVE — mobile  (≤520px)
================================================================ */
@media (max-width: 520px) {
  .page-title { font-size: 18px; }

  .input-type-tabs { gap: 5px; }
  .tab-btn { padding: 7px 10px; font-size: 11px; }
  .tab-btn svg { width: 18px; height: 18px; }

  .qr-frame { width: 180px; height: 180px; }

}
