:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #111827;
  --danger: #b91c1c;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px 36px;
}

.wrap {
  width: 100%;
  max-width: 980px;
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;
}

.wallet {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-weight: 900;
  font-size: 13px;
}

.wallet span {
  color: var(--muted);
  font-weight: 900;
}

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.subtext {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.smalltitle {
  margin: 0 0 10px;
  font-weight: 800;
  color: var(--text);
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  min-height: 110px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.tile h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.tile p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.tilelink {
  text-decoration: none;
  color: inherit;
  display: block;
}

.tilelink:hover .tile { border-color: #cbd5e1; }

/* Reusable layout helpers (Producer Dashboard, etc.) */
.container {
  width: 100%;
  max-width: 980px;
  display: grid;
  gap: 14px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px;
}

.header-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

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

.link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  color: var(--text);
  font-weight: 900;
}

.link:hover { border-color: #cbd5e1; }

.cardgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.navcard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  padding: 16px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.navcard:hover { border-color: #cbd5e1; }

.navcard-title {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
}

.navcard-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.navcard-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  font-weight: 900;
  color: var(--muted);
}

.idol-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.idol-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.idol-name {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
}

.idol-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metaitem {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.metalabel {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}

.metavalue {
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
}

.mini-stats {
  display: grid;
  gap: 8px;
}

.mini-stat {
  display: grid;
  gap: 6px;
}

.mini-stathead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.mini-statname {
  font-weight: 900;
  font-size: 12px;
}

.mini-statval {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
}

.mini-bar {
  height: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9fafb;
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  width: 0%;
}

.linkrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;
}

.linkrow:hover { text-decoration: underline; }

.two-col {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
  align-items: start;
}

.profile {
  display: grid;
  gap: 10px;
}

.profilelist {
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

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

.v {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  word-break: break-word;
}

.stats {
  display: grid;
  gap: 10px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.stathead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.statname {
  font-weight: 800;
  font-size: 13px;
}

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

.bar {
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9fafb;
  overflow: hidden;
}

.fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  width: 0%;
}

.actions {
  display: grid;
  gap: 10px;
}

/* Sidebar navigation (left rail)
   - Links stack vertically, text stays horizontal.
   - On mobile, becomes a top horizontal menu.
*/
.layout {
  width: 100%;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);

  /* Always keep text horizontal within the sidebar */
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

.sidebar * {
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 900;
  font-size: 14px;
  border: 1px solid transparent;
  background: transparent;

  /* Ensure glyphs stay horizontal even if parent gets rotated */
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

.sidebar-link:hover {
  background: #ffffff;
  border-color: var(--border);
}

.sidebar-link[aria-current="page"],
.sidebar-link.is-active {
  background: #ffffff;
  border-color: var(--border);
}

.sidebar-link:focus-visible {
  outline: none;
  border-color: #cbd5e1;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.25);
}

.btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-secondary {
  background: #ffffff;
  color: var(--text);
  border-color: var(--border);
}

.btn-danger {
  background: #ffffff;
  color: var(--danger);
  border-color: #fecaca;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.notice {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.12);
  font-weight: 900;
  font-size: 13px;
  color: var(--text);
  display: none;
  z-index: 50;
}

.toast.show { display: inline-flex; }

.select {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  outline: none;
}

.input {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  outline: none;
}

.select:focus {
  border-color: #cbd5e1;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.25);
}

.input:focus {
  border-color: #cbd5e1;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.25);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 11px;
  font-weight: 900;
  color: var(--muted);
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .idol-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }

  /* Sidebar -> top horizontal menu */
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .sidebar-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-link {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .page { padding: 18px 12px 24px; }
  .card { padding: 16px; }
  .wallet { gap: 8px; }
  .cardgrid { grid-template-columns: 1fr; }
  .navcard { min-height: 128px; padding: 14px; }
}
