:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --text: #1c2230;
  --muted: #6b7385;
  --border: #e4e7ef;
  --accent: #3b5bfd;
  --accent-2: #2b46e0;
  --accent-soft: #eef1ff;
  --ok: #17915a;
  --ok-soft: #e6f6ee;
  --err: #d23b3b;
  --err-soft: #fdecec;
  --money: #b8791b;
  --money-soft: #fcf3e3;
  --shadow: 0 1px 2px rgba(20,28,50,.04), 0 8px 24px rgba(20,28,50,.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 900px; margin: 0 auto;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.logo { font-size: 18px; font-weight: 800; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.nav { display: flex; align-items: center; gap: 12px; }
.nav-link { color: var(--muted); text-decoration: none; font-size: 14px; }
.nav-link:hover { color: var(--text); }
.nav-email { color: var(--muted); font-size: 13px; }

.plan-badge {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.plan-ad_free { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.plan-custom  { background: #eafaf1; color: var(--ok); border-color: transparent; }

/* ---------- Layout ---------- */
.wrap { max-width: 900px; margin: 0 auto; padding: 24px 16px 120px; }

.hero { padding: 4px 4px 10px; }
.hero h1 { font-size: 28px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -.02em; }
.hero .lead { color: var(--muted); margin: 0; max-width: 640px; }
@media (max-width: 480px) { .hero h1 { font-size: 25px; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card-narrow { max-width: 420px; margin-left: auto; margin-right: auto; margin-top: 32px; }
.card.center { text-align: center; }

h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 0 0 14px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
input {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { background: var(--surface-2); color: var(--muted); }

.alias-row {
  display: flex; align-items: stretch; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; background: var(--surface);
}
.alias-prefix {
  display: flex; align-items: center; padding: 0 12px; color: var(--muted);
  font-size: 13px; background: var(--surface-2); white-space: nowrap;
}
.alias-row input { border: none; border-radius: 0; }
.alias-row input:focus { box-shadow: none; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.hint a { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; margin-top: 18px; width: 100%; padding: 12px;
  border: none; border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer; text-align: center; text-decoration: none;
}
.btn:hover { background: var(--accent-2); }
.btn:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.btn-sm { width: auto; margin: 0; padding: 8px 14px; font-size: 14px; border-radius: 9px; }
.btn-ghost { background: var(--surface); color: var(--accent); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-white { width: auto; margin: 0; padding: 9px 16px; background: #fff; color: var(--accent); }
.btn-white:hover { background: #f0f2ff; }

/* ---------- Tags ---------- */
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-lock { background: var(--surface-2); color: var(--muted); }
.tag-money { background: var(--money-soft); color: var(--money); }
.tag-progress { background: var(--accent-soft); color: var(--accent); }

/* ---------- Link cards ---------- */
.cards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 620px) { .cards { grid-template-columns: minmax(0, 1fr); } }
.linkcard {
  border: 1px solid var(--border); border-radius: 13px; padding: 14px; background: var(--surface);
  min-width: 0; /* グリッド内で中身の長いURL等に押し広げられないように */
}
.linkcard-img { margin: -14px -14px 12px; border-radius: 12px 12px 0 0; overflow: hidden; background: var(--surface-2); }
.linkcard-img img { display: block; width: 100%; height: 150px; object-fit: cover; }
.file-input { font-size: 14px; padding: 9px 11px; }
.file-input::file-selector-button {
  margin-right: 10px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-size: 13px; cursor: pointer;
}
.file-input::file-selector-button:hover { background: var(--accent-soft); color: var(--accent); }
.image-preview { margin-top: 12px; }
.image-preview-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.image-preview-card { max-width: 280px; border: 1px solid var(--border); border-radius: 13px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.image-preview-card img { display: block; width: 100%; height: 150px; object-fit: cover; background: var(--surface-2); }
.linkcard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.linkcard-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkcard-url { display: flex; align-items: center; gap: 8px; }
a.short { color: var(--accent); text-decoration: none; font-weight: 700; font-size: 14px; word-break: break-all; }
a.short:hover { text-decoration: underline; }
.copy { background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 3px 8px; font-size: 12px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.copy:hover { color: var(--text); }
.linkcard-dest { color: var(--muted); font-size: 12px; margin: 6px 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkcard-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 10px; }
.clicks { font-size: 13px; color: var(--muted); font-weight: 600; }
.stats-link { font-size: 13px; color: var(--accent); text-decoration: none; }
.empty { color: var(--muted); }

/* ---------- Flashes ---------- */
.flashes { margin-bottom: 16px; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; word-break: break-all; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); border-color: #bfe8d1; color: #0f6b41; }
.flash-error { background: var(--err-soft); border-color: #f4c7c7; color: #a12626; }

/* ---------- Stats ---------- */
.stat-grid { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px 22px; text-align: center; min-width: 120px; }
.stat-num { font-size: 30px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); }
dl.detail { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; font-size: 14px; }
dl.detail dt { color: var(--muted); }
dl.detail dd { margin: 0; word-break: break-all; }
.back { text-decoration: none; }
.switch { text-align: center; color: var(--muted); font-size: 14px; margin-top: 16px; }

/* ---------- Pricing ---------- */
.plans { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 860px) { .plans { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .plans { grid-template-columns: 1fr; } }
.plan { border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; }
.plan-featured { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan-current { outline: 2px solid var(--ok); }
.plan-name { font-weight: 800; font-size: 15px; }
.plan-price { font-size: 26px; font-weight: 800; margin: 6px 0 12px; }
.plan-price span { font-size: 13px; font-weight: 600; color: var(--muted); }
.plan-feats { list-style: none; padding: 0; margin: 0 0 14px; font-size: 13px; color: var(--muted); flex: 1; }
.plan-feats li { padding: 4px 0 4px 20px; position: relative; }
.plan-feats li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 800; }
.demo-note { font-size: 12px; color: var(--muted); margin: 14px 0 0; }

/* ---------- Bottom bar ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--accent); color: #fff;
}
.bottombar-inner {
  max-width: 900px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.bottombar-text { font-size: 14px; font-weight: 600; }
.bottombar .btn-white { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 480px) {
  .bottombar-inner { padding: 10px 14px; gap: 10px; }
  .bottombar-text { font-size: 12.5px; line-height: 1.35; }
  .bottombar .btn-white { padding: 9px 14px; font-size: 14px; }
}

/* ---------- Interstitial ---------- */
.interstitial-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.interstitial { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; max-width: 440px; width: 100%; text-align: center; }
.inter-kicker { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.sponsor { display: block; text-decoration: none; border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: var(--surface-2); margin-bottom: 18px; text-align: left; }
.sponsor:hover { border-color: var(--accent); }
.sponsor-badge { display: inline-block; font-size: 11px; font-weight: 800; color: var(--money); background: var(--money-soft); padding: 2px 8px; border-radius: 999px; }
.sponsor-title { display: block; font-weight: 800; color: var(--text); margin: 8px 0 2px; font-size: 16px; }
.sponsor-url { display: block; color: var(--muted); font-size: 12px; word-break: break-all; }
.sponsor-cta { display: inline-block; margin-top: 8px; color: var(--accent); font-weight: 800; font-size: 14px; }
.btn-continue { background: var(--surface-2); color: var(--muted); }
.btn-continue.ready { background: var(--accent); color: #fff; }
.inter-count { color: var(--text); font-size: 14px; font-weight: 700; margin: 4px 0 10px; }
.inter-count #count { color: var(--accent); }
.inter-skip { display: inline-block; color: var(--muted); font-size: 13px; text-decoration: none; }
.inter-skip:hover { color: var(--text); text-decoration: underline; }
.inter-note { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

/* ---------- Hamburger ---------- */
.hamburger {
  width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; padding: 0;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: .2s; }
.hamburger:hover { background: var(--surface-2); }
.drawer-open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.drawer-open .hamburger span:nth-child(2) { opacity: 0; }
.drawer-open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Drawer (right slide-in) ---------- */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(20,28,50,.38);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease; z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 300px; max-width: 84vw;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -12px 0 30px rgba(20,28,50,.12);
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  z-index: 50; display: flex; flex-direction: column;
}
.drawer-open .drawer-overlay { opacity: 1; visibility: visible; }
.drawer-open .drawer { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-title { font-weight: 800; }
.drawer-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); line-height: 1; }
.drawer-close:hover { color: var(--text); }
.drawer-nav { padding: 8px; overflow-y: auto; }
.drawer-nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-size: 15px; font-weight: 600;
}
.drawer-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.drawer-nav .di { width: 22px; text-align: center; font-size: 16px; }
.drawer-sep { height: 1px; background: var(--border); margin: 8px 6px; }

/* ---------- Stats bar ---------- */
.statsbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 480px) { .statsbar { gap: 8px; } }
.statbox {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.statbox-num { font-size: 26px; font-weight: 800; color: var(--accent); line-height: 1.2; }
.statbox-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Simple content pages ---------- */
.notice { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.notice-date { font-size: 12px; color: var(--muted); }
.notice-title { font-weight: 700; margin: 2px 0 4px; }
.notice-body { font-size: 14px; color: var(--muted); }
.doc h3 { font-size: 15px; margin: 18px 0 6px; }
.doc p, .doc li { color: var(--muted); font-size: 14px; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th, .history-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }
.history-table th { color: var(--muted); font-size: 12px; }
.nav-hide-sm { }
@media (max-width: 420px) { .nav-hide-sm { display: none; } }

/* ---------- Original page editor ---------- */
.page-url { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.page-url-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.linkadd { margin-bottom: 14px; }
.linkadd-row { display: flex; gap: 8px; align-items: stretch; }
.linkadd-row input { flex: 1; }
.linkadd-row input:first-child { max-width: 220px; }
.linkadd-row .btn-sm { white-space: nowrap; align-self: center; }
@media (max-width: 560px) { .linkadd-row { flex-direction: column; } .linkadd-row input:first-child { max-width: none; } }
.pl-list { display: flex; flex-direction: column; gap: 10px; }
.pl-item { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface); }
.pl-edit { display: flex; gap: 8px; align-items: center; }
.pl-edit input { flex: 1; }
.pl-edit input:first-child { max-width: 200px; }
.pl-edit .btn-sm { white-space: nowrap; }
@media (max-width: 560px) { .pl-edit { flex-direction: column; align-items: stretch; } .pl-edit input:first-child { max-width: none; } }
.pl-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.pl-actions { display: flex; gap: 6px; }
.pl-actions form { margin: 0; }
.pl-btn { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; }
.pl-btn:hover { background: var(--surface-2); color: var(--text); }
.pl-del:hover { background: var(--err-soft); color: var(--err); border-color: #f4c7c7; }

/* ---------- Logout buttons (POST forms styled as links) ---------- */
.inline-form { display: inline; margin: 0; }
.linklike {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  color: var(--muted); font-size: 14px; font-family: inherit;
}
.linklike:hover { color: var(--text); }
.drawer-form { margin: 0; }
.drawer-form button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border: none; border-radius: 10px; background: none;
  color: var(--text); text-decoration: none; font-size: 15px; font-weight: 600;
  font-family: inherit; cursor: pointer; text-align: left;
}
.drawer-form button:hover { background: var(--accent-soft); color: var(--accent); }
.drawer-form .di { width: 22px; text-align: center; font-size: 16px; }
