:root {
  color-scheme: light;
  --background: #f6f7f4;
  --surface: #ffffff;
  --surface-strong: #eef4f2;
  --text: #17211d;
  --muted: #69756f;
  --line: #d9e0dc;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(24, 39, 34, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: var(--background);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(300px, 0.85fr) minmax(420px, 1.1fr);
  gap: 20px;
  align-items: start;
}

.auth-page {
  min-height: 100vh;
  width: min(440px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: 40px 0;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 30px;
}

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 18px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.topbar h1 {
  font-size: 30px;
}

.account-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.account-actions span {
  color: var(--muted);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dashboard-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 40px;
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel,
.composer {
  padding: 28px;
  position: sticky;
  top: 24px;
}

.composer {
  top: 292px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.15;
}

h2 {
  font-size: 22px;
}

.lead {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.form {
  margin-top: 28px;
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}

label span {
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fbfcfb;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: #e1ebe7;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.danger {
  background: #fff1ef;
  color: var(--danger);
  border: 1px solid #ffd2cc;
}

button.danger:hover {
  background: #ffe3df;
}

.result {
  margin-top: 18px;
  padding: 14px;
  border-radius: 6px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.result a {
  color: var(--accent-dark);
  font-weight: 700;
}

.account-settings {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.account-settings h2 {
  font-size: 18px;
}

.compact-form {
  margin-top: 16px;
  gap: 12px;
}

.auth-tabs {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab-button {
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}

.tab-button:hover,
.tab-button.active {
  background: var(--surface);
  color: var(--text);
}

.account-box {
  margin-top: 24px;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.account-box strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

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

.message {
  margin-top: 14px;
  color: var(--accent-dark);
  font-weight: 700;
}

.message.error {
  color: var(--danger);
}

.list-panel,
.analytics-panel {
  min-height: 520px;
  min-width: 0;
}

.list-header {
  padding: 22px 22px 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.link-list {
  display: grid;
}

.empty {
  padding: 52px 24px;
  color: var(--muted);
  text-align: center;
}

.link-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  padding: 18px 22px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.analytics-item {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.summary-card {
  padding: 14px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.summary-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.analytics-detail {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding-top: 4px;
}

.analytics-detail > div {
  min-width: 0;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.analytics-detail h3 {
  margin: 0 0 10px;
  font-size: 13px;
}

.analytics-detail ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.analytics-detail li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  min-width: 0;
}

.analytics-detail li span {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.analytics-detail li strong {
  color: var(--text);
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: right;
}

.link-item:last-child {
  border-bottom: 0;
}

.link-main {
  min-width: 0;
}

.link-title {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.35;
}

.short-link {
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

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

.destination {
  margin: 6px 0 0;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 88px);
  gap: 8px;
}

.stats div {
  padding: 10px 12px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.stats dt {
  color: var(--muted);
  font-size: 12px;
}

.stats dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.actions {
  display: flex;
  gap: 8px;
}

.actions button {
  min-width: 72px;
}

@media (max-width: 900px) {
  .app-shell,
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .auth-panel,
  .composer {
    position: static;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 20px 0;
  }

  .auth-page,
  .dashboard-shell,
  .topbar {
    width: min(100% - 20px, 1120px);
  }

  .composer,
  .auth-card,
  .list-header,
  .link-item {
    padding-left: 16px;
    padding-right: 16px;
  }

  h1 {
    font-size: 28px;
  }

  .link-item {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .analytics-detail {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }
}
