/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #2563eb;
  --brand-dark:  #1d4ed8;
  --brand-light: #dbeafe;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --surface:     #ffffff;
  --bg:          #f1f5f9;
  --border:      #e2e8f0;
  --radius:      14px;
  --shadow:      0 4px 24px rgba(0,0,0,.08);
  --font:        'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Container === */
.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

/* === Header === */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,.04);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.logo-mark {
  background: var(--brand);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 900;
}

.logo-text { color: var(--text); }

/* === Hero === */
.hero {
  flex: 1;
  padding: 64px 0 80px;
}

.hero-title {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 16px;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 40px;
}

.domain {
  font-weight: 700;
  color: var(--brand);
}

/* === Card === */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px;
  margin-bottom: 48px;
}

/* === Input Group === */
.input-group {
  display: flex;
  gap: 10px;
}

#url-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color .2s;
  background: var(--bg);
  color: var(--text);
}

#url-input:focus { border-color: var(--brand); background: #fff; }
#url-input::placeholder { color: #94a3b8; }

#submit-btn {
  padding: 14px 26px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, transform .1s;
}

#submit-btn:hover  { background: var(--brand-dark); }
#submit-btn:active { transform: scale(.97); }
#submit-btn:disabled { opacity: .6; cursor: not-allowed; }

.input-hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* === Result === */
.result {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.result-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.result-url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#result-link {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--brand);
  text-decoration: none;
  word-break: break-all;
}

#result-link:hover { text-decoration: underline; }

.copy-btn {
  background: var(--brand-light);
  border: none;
  border-radius: 8px;
  color: var(--brand);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}

.copy-btn:hover { background: #bfdbfe; }

.stats-link {
  display: inline-block;
  font-size: .88rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 6px;
}

.stats-link:hover { color: var(--brand); text-decoration: underline; }

.copy-msg {
  font-size: .85rem;
  color: #16a34a;
  font-weight: 600;
  margin-top: 4px;
}

/* === Error inside card === */
.error-msg {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #dc2626;
  font-size: .9rem;
}

/* === Features === */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

.feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.feature-icon { font-size: 1.6rem; flex-shrink: 0; }
.feature h3   { font-size: .95rem; font-weight: 700; margin-bottom: 2px; }
.feature p    { font-size: .82rem; color: var(--text-muted); }

/* === Stats page === */
.page-content {
  padding: 56px 0 80px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 28px;
}

.stats-card { padding: 32px; }

.stats-url-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 24px;
}

.stats-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.stats-short-url {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--brand);
  text-decoration: none;
  word-break: break-all;
}

.stats-short-url:hover { text-decoration: underline; }

.stats-original-url {
  font-size: .9rem;
  color: var(--text-muted);
  text-decoration: none;
  word-break: break-all;
}

.stats-original-url:hover { color: var(--brand); text-decoration: underline; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.stat-box {
  background: var(--bg);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.02em;
}

.stat-name {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
}

.back-link-row { margin-top: 24px; }

.back-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
}

.back-link:hover { text-decoration: underline; }

/* === Error page === */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 50vh;
  gap: 16px;
}

.error-code {
  font-size: 6rem;
  font-weight: 900;
  color: var(--brand);
  letter-spacing: -0.05em;
  line-height: 1;
}

.error-message {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.btn-primary {
  display: inline-block;
  padding: 12px 28px;
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  margin-top: 8px;
  transition: background .2s;
}

.btn-primary:hover { background: var(--brand-dark); }

/* === Footer === */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* === Responsive === */
@media (max-width: 520px) {
  .card { padding: 24px 20px; }
  .input-group { flex-direction: column; }
  #submit-btn { width: 100%; }
  .hero { padding: 40px 0 56px; }
}
