:root {
  --bg: #0a0f19;
  --panel: #111827;
  --panel-2: #172033;
  --line: #263247;
  --text: #edf3ff;
  --muted: #9aabc4;
  --accent: #5865f2;
  --accent-2: #7c87ff;
  --success: #35c788;
  --danger: #ff6b7a;
  --shadow: 0 18px 60px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(88, 101, 242, .20), transparent 34rem),
    radial-gradient(circle at 100% 20%, rgba(56, 189, 248, .10), transparent 30rem),
    var(--bg);
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 48px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  background: rgba(17, 24, 39, .78);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  position: sticky;
  top: 14px;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: transparent;
  box-shadow: none;
  font-weight: 900;
  overflow: hidden;
}
.brand-mark img, .login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-mark.logo-missing, .login-logo.logo-missing { display: none; }
.brand h1 { margin: 0; font-size: 18px; letter-spacing: .02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.user-info { display: grid; gap: 1px; text-align: right; min-width: 0; }
.user-info-label { color: var(--muted); font-size: 10px; line-height: 1.2; }
.user-info-name { color: #dbe5f7; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }

.btn {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 13px;
  color: var(--text);
  background: #172033;
  transition: .16s ease;
}
.btn:hover { transform: translateY(-1px); border-color: #41506b; background: #1d2940; }
.btn:focus-visible, input:focus-visible, select:focus-visible, .dropdown-trigger:focus-visible, .dropdown-option:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
.btn-primary { border-color: transparent; background: var(--accent); font-weight: 700; }
.btn-primary:hover { background: #6874ff; }
.btn-danger { color: #ffc2c8; }
.btn-small { padding: 7px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.summary {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat {
  padding: 15px 17px;
  background: rgba(17, 24, 39, .72);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
}
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { margin-top: 7px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toolbar {
  margin: 18px 0 12px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.search {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(17, 24, 39, .78);
  color: var(--text);
  padding: 12px 14px;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 1px 12px;
}
.tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(17, 24, 39, .62);
}
.tab.active { color: white; border-color: rgba(124, 135, 255, .65); background: rgba(88, 101, 242, .24); }
.tab-count { margin-left: 5px; opacity: .7; }

.notice { margin: 12px 0; padding: 12px 14px; border: 1px solid rgba(255, 107, 122, .35); border-radius: 12px; color: #ffc3ca; background: rgba(255,107,122,.08); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  min-width: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 14px;
  padding: 15px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(24, 34, 54, .94), rgba(15, 22, 36, .94));
  box-shadow: 0 12px 35px rgba(0,0,0,.15);
}
.preview {
  width: 76px; height: 76px;
  display: grid; place-items: center;
  border-style: solid;
  border-width: 3px;
  border-color: #d0d0d0 #373737 #373737 #d0d0d0;
  border-radius: 2px;
  background: #8b8b8b;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.14), inset -2px -2px 0 rgba(0,0,0,.22);
}
.preview img { width: 66px; height: 66px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 3px 2px rgba(0,0,0,.38)); }
.preview-fallback { color: var(--muted); font-size: 11px; text-align: center; }
.preview.preview-error { cursor: help; }
.card-body { min-width: 0; }
.card-title { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.card-title.unset { color: #aebbd0; font-weight: 500; }
.item-id { margin-top: 5px; color: #8fc9ff; font-size: 12px; }
.cmd { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.model-paths { display: grid; gap: 3px; margin-top: 5px; }
.model-path { color: #74859f; font-size: 11px; overflow-wrap: anywhere; word-break: break-word; white-space: normal; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.empty { padding: 64px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(720px, 100%);
  padding: 32px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 22px;
  background: rgba(17, 24, 39, .9);
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { width: 76px; height: 76px; margin: 0 auto 18px; display: grid; place-items: center; background: transparent; overflow: hidden; }
.login-card h1 { margin: 0 0 10px; white-space: nowrap; }
.login-card p { margin: 0; color: var(--muted); line-height: 1.8; }
.login-messages { display: grid; gap: 10px; margin-top: 24px; }
.login-actions { display: grid; gap: 10px; margin-top: 24px; }
.login-card .btn { width: 100%; padding: 13px; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.login-card .btn:visited { color: var(--text); }
.config-error { margin: 0; padding: 11px 13px; border: 1px solid rgba(255, 107, 122, .35); border-radius: 10px; color: #ffc3ca; background: rgba(255, 107, 122, .08); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.68); backdrop-filter: blur(5px); }
.modal { width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: #101827; box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 18px; font-size: 19px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 12px; }
.field-spaced { margin-top: 16px; }
.clipboard-fallback { position: fixed; opacity: 0; pointer-events: none; }
.input, .select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); background: #162137; padding: 10px 11px;
}

.dropdown { position: relative; width: 100%; }
.dropdown-trigger {
  position: relative;
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: #162137;
  padding: 10px 44px 10px 11px;
  text-align: left;
}
.dropdown-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.color-dropdown-value {
  display: flex;
  align-items: center;
  gap: 9px;
}
.dropdown-arrow {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 13px;
  height: 13px;
  border-right: 3px solid #c8d3e6;
  border-bottom: 3px solid #c8d3e6;
  transform: translateY(-68%) rotate(45deg);
  transform-origin: center;
  pointer-events: none;
  transition: transform .16s ease;
}
.dropdown.open .dropdown-arrow {
  transform: translateY(-32%) rotate(225deg);
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #121d31;
  box-shadow: 0 16px 36px rgba(0,0,0,.34);
}
.dropdown-option {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  text-align: left;
}
.color-dropdown-option {
  display: flex;
  align-items: center;
  gap: 9px;
}
.dropdown-option:hover,
.dropdown-option:focus-visible { background: rgba(88, 101, 242, .18); }
.dropdown-option.selected {
  background: rgba(88, 101, 242, .26);
  color: #ffffff;
  font-weight: 650;
}

.color-control {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(150px, .65fr);
  gap: 10px;
  align-items: start;
}
.color-swatch {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  border: 1px solid rgba(255, 255, 255, .48);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .28);
}
.color-swatch-empty {
  position: relative;
  background:
    linear-gradient(45deg, #c4ccda 25%, transparent 25%, transparent 75%, #c4ccda 75%),
    linear-gradient(45deg, #c4ccda 25%, #ffffff 25%, #ffffff 75%, #c4ccda 75%);
  background-position: 0 0, 4px 4px;
  background-size: 8px 8px;
}
.color-swatch-empty::after {
  content: "";
  position: absolute;
  left: -2px;
  top: 5px;
  width: 15px;
  height: 2px;
  border-radius: 2px;
  background: #ff6b7a;
  transform: rotate(-45deg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .14);
}
.hex-color-box {
  position: relative;
  display: flex;
  align-items: center;
}
.hex-color-input {
  min-height: 43px;
  padding-right: 43px;
  font-family: "Cascadia Code", Consolas, monospace;
  text-transform: uppercase;
}
.hex-color-box.invalid .hex-color-input {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(255, 107, 122, .22);
}
.color-picker-button {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 23px;
  height: 23px;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 5px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .28);
  overflow: hidden;
  cursor: pointer;
}
.color-picker-button:hover {
  border-color: #ffffff;
  transform: translateY(-50%) scale(1.05);
}
.color-picker-button:focus-within {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
.color-picker-preview {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 3px;
  box-shadow: none;
}
.native-color-picker {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.checks { display: flex; flex-wrap: wrap; gap: 12px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.checks.disabled { opacity: .48; }
.check input:disabled { cursor: not-allowed; }
.command-box { min-height: 92px; padding: 12px; border-radius: 11px; background: #080d16; border: 1px solid #202b3f; color: #b8e6c8; font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; }
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 9px; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; transform: translateY(20px); opacity: 0; pointer-events: none; padding: 11px 14px; border-radius: 11px; background: #22304b; border: 1px solid #3b4a66; color: white; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { transform: translateY(0); opacity: 1; }
.loading { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 820px) {
  .shell { width: min(100% - 20px, 1440px); padding-top: 10px; }
  .topbar { top: 8px; align-items: flex-start; }
  .summary { grid-template-columns: 1fr 1fr; }
  .user-info { display: none; }
}
@media (max-width: 560px) {
  .brand p { display: none; }
  .topbar { padding: 14px; }
  .summary { grid-template-columns: 1fr; }
  .toolbar { display: block; }
  .search { width: 100%; }
  .grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .color-control { grid-template-columns: 1fr; }
  .card { grid-template-columns: 62px minmax(0, 1fr); }
  .preview { width: 62px; height: 62px; }
  .preview img { width: 54px; height: 54px; }
}
@media (max-width: 720px) {
  .login-card h1 { white-space: normal; }
}
