:root {
    --rankor-bg: #0a0e13;
    --rankor-surface: rgba(14, 18, 23, 0.82);
    --rankor-surface-strong: rgba(10, 14, 19, 0.94);
    --rankor-border: rgba(255, 255, 255, 0.05);
    --rankor-border-strong: rgba(255, 70, 85, 0.18);
    --rankor-red: #ff4655;
    --rankor-green: #18e5b8;
    --rankor-text: #eef2f7;
    --rankor-muted: #9ca7b8;
    --rankor-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(255, 70, 85, 0.16), transparent 30%),
        radial-gradient(circle at bottom right, rgba(24, 229, 184, 0.10), transparent 26%),
        linear-gradient(180deg, #05070a 0%, #0a0e13 42%, #05070a 100%);
    color: var(--rankor-text);
    font-family: "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    overflow: hidden;
}

body.rankor-mode-builder {
    overflow: hidden;
}

html.rankor-mode-overlay,
body.rankor-mode-overlay {
    background: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

#rankor-app {
    min-height: 100vh;
}

.rankor-builder-shell,
.rankor-overlay-shell {
    min-height: 100vh;
}

.rankor-builder-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}

.rankor-topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 14px 18px;
    background: rgba(8, 10, 13, 0.72);
    backdrop-filter: blur(16px);
}

.rankor-topbar-kicker,
.rankor-overlay-title {
    font-size: 12px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--rankor-muted);
}

.rankor-topbar-title {
    margin-top: 4px;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.rankor-topbar-meta,
.rankor-overlay-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    text-align: right;
    font-size: 13px;
    color: var(--rankor-muted);
}

.rankor-topbar-user,
.rankor-topbar-template,
.rankor-topbar-status,
.rankor-overlay-meta span {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rankor-topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.rankor-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 340px;
    gap: 14px;
    padding: 14px;
    min-height: 0;
    flex: 1;
    height: 100%;
    align-items: stretch;
    overflow: hidden;
}

.rankor-sidebar,
.rankor-inspector {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 4px;
}

.rankor-sidebar > *,
.rankor-inspector > *,
.rankor-section {
    background: var(--rankor-surface);
    border: 0;
    border-radius: 14px;
    box-shadow: var(--rankor-shadow);
    backdrop-filter: blur(16px);
}

.rankor-section {
    padding: 14px;
}

.rankor-section-header {
    margin-bottom: 14px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--rankor-muted);
}

.rankor-template-list,
.rankor-toolbar,
.rankor-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.rankor-template-pill,
.rankor-chip,
.rankor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--rankor-text);
    padding: 10px 12px;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.rankor-template-pill:hover,
.rankor-chip:hover,
.rankor-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.08);
}

.rankor-template-pill.is-active,
.rankor-chip.is-active,
.rankor-btn-accent {
    background: linear-gradient(135deg, rgba(255, 70, 85, 0.92), rgba(193, 31, 47, 0.92));
    box-shadow: 0 10px 24px rgba(255, 70, 85, 0.2);
}

.rankor-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.rankor-input-group span {
    font-size: 12px;
    color: var(--rankor-muted);
    font-weight: 700;
    letter-spacing: 0.06em;
}

.rankor-input,
.rankor-textarea {
    width: 100%;
    border: 0;
    border-radius: 10px;
    background: rgba(7, 10, 13, 0.82);
    color: var(--rankor-text);
    padding: 11px 12px;
    outline: none;
}

.rankor-textarea {
    min-height: 120px;
    resize: vertical;
}

.rankor-input:focus,
.rankor-textarea:focus {
    box-shadow: 0 0 0 3px rgba(255, 70, 85, 0.12);
}

.rankor-grid-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.rankor-canvas-area {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
}

.rankor-stage-frame {
    width: min(100%, 1280px);
    aspect-ratio: 16 / 9;
    position: relative;
    border-radius: 16px;
    background: rgba(7, 10, 13, 0.52);
    box-shadow: var(--rankor-shadow);
    overflow: hidden;
}

.rankor-stage-shell {
    width: min(100%, 1280px);
    aspect-ratio: 16 / 9;
    position: relative;
    border-radius: 16px;
    background: rgba(7, 10, 13, 0.52);
    box-shadow: var(--rankor-shadow);
    overflow: hidden;
}

.rankor-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: transparent;
}

.rankor-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 64px 64px;
    opacity: 0.18;
    pointer-events: none;
}

.rankor-item {
    position: absolute;
    overflow: visible;
}

.rankor-item.is-editable {
    cursor: move;
}

.rankor-item.is-editable > :not(.rankor-resize-handle),
.rankor-item.is-editable > :not(.rankor-resize-handle) * {
    pointer-events: none;
}

.rankor-item.is-selected {
    outline: 2px solid rgba(255, 70, 85, 0.82);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.rankor-resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 0;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(255, 70, 85, 0.86);
    padding: 0;
    cursor: nwse-resize;
    z-index: 8;
}

.rankor-resize-handle.is-nw {
    top: -7px;
    left: -7px;
}

.rankor-resize-handle.is-ne {
    top: -7px;
    right: -7px;
    cursor: nesw-resize;
}

.rankor-resize-handle.is-sw {
    bottom: -7px;
    left: -7px;
    cursor: nesw-resize;
}

.rankor-resize-handle.is-se {
    right: -7px;
    bottom: -7px;
}

.rankor-panel-fill {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: inherit;
}

.rankor-text {
    white-space: pre-wrap;
    line-height: 1.12;
}

.rankor-image {
    width: 100%;
    height: 100%;
    display: block;
}

.rankor-rank,
.rankor-stat,
.rankor-bar,
.rankor-agents {
    width: 100%;
    height: 100%;
}

.rankor-rank {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rankor-rank-icon-wrap {
    width: 74px;
    height: 74px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
}

.rankor-rank-icon {
    width: 74px;
    height: 74px;
    object-fit: contain;
}

.rankor-rank-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rankor-rank-name {
    font-size: 28px;
    font-weight: 900;
    line-height: 1;
}

.rankor-rank-rr {
    font-size: 15px;
    color: var(--rankor-muted);
    font-weight: 800;
}

.rankor-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.rankor-stat-label {
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rankor-muted);
    font-weight: 800;
}

.rankor-stat-value {
    font-size: 40px;
    line-height: 1;
    font-weight: 900;
}

.rankor-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

.rankor-bar-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.rankor-bar-head.is-label-only {
    justify-content: flex-start;
}

.rankor-bar-label {
    font-size: 14px;
    color: var(--rankor-muted);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rankor-bar-value {
    font-size: 22px;
    font-weight: 900;
}

.rankor-bar-track {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}

.rankor-bar-fill {
    height: 100%;
    border-radius: inherit;
}

.rankor-agents {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.rankor-section-title {
    font-size: 13px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--rankor-muted);
    font-weight: 800;
}

.rankor-agent-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.rankor-agent-grid.is-empty {
    min-height: 1px;
}

.rankor-agent-card {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: 0;
}

.rankor-agent-icon {
    width: 52px;
    height: 52px;
    border-radius: 0;
    object-fit: contain;
    background: transparent;
}

.rankor-agent-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rankor-agent-name {
    font-size: 17px;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.rankor-empty,
.rankor-empty-panel {
    display: grid;
    place-items: center;
    min-height: 90px;
    color: var(--rankor-muted);
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 18px;
}

.rankor-part-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rankor-part-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px;
}

.rankor-part-chip.is-token {
    background: rgba(255, 70, 85, 0.16);
}

.rankor-part-body,
.rankor-part-mini {
    border: 0;
    background: transparent;
    color: var(--rankor-text);
    cursor: pointer;
}

.rankor-part-body {
    padding: 6px 8px;
    border-radius: 8px;
}

.rankor-part-mini {
    padding: 4px 6px;
    border-radius: 8px;
    color: var(--rankor-muted);
}

.rankor-inline-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.rankor-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.rankor-chip {
    font-size: 12px;
    padding: 8px 12px;
}

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

.rankor-catalog-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.rankor-catalog-card {
    width: 100%;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--rankor-text);
    padding: 12px;
    text-align: left;
    cursor: grab;
}

.rankor-catalog-card:active {
    cursor: grabbing;
}

.rankor-catalog-head {
    margin-bottom: 10px;
}

.rankor-catalog-title {
    font-size: 14px;
    font-weight: 800;
}

.rankor-catalog-desc {
    margin-top: 4px;
    font-size: 12px;
    color: var(--rankor-muted);
}

.rankor-context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 120px;
    padding: 8px;
    border-radius: 12px;
    background: rgba(8, 10, 13, 0.96);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(18px);
}

.rankor-context-btn {
    width: 100%;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--rankor-text);
    text-align: left;
    padding: 10px 12px;
    cursor: pointer;
}

.rankor-context-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.rankor-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9998;
    min-width: 180px;
    max-width: 320px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(8, 10, 13, 0.92);
    color: var(--rankor-text);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.rankor-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.rankor-catalog-preview {
    min-height: 54px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rankor-catalog-preview-rank {
    gap: 12px;
}

.rankor-catalog-rank-icon {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 70, 85, 0.95), rgba(255, 180, 88, 0.9));
}

.rankor-catalog-rank-lines {
    flex: 1;
}

.rankor-catalog-line {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
}

.rankor-catalog-line + .rankor-catalog-line {
    margin-top: 8px;
}

.rankor-catalog-line.long {
    width: 74%;
}

.rankor-catalog-line.short {
    width: 40%;
}

.rankor-catalog-number {
    font-size: 28px;
    font-weight: 900;
    color: var(--rankor-red);
}

.rankor-catalog-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.rankor-catalog-bar-fill {
    width: 62%;
    height: 100%;
    background: #18e5b8;
}

.rankor-catalog-preview-strip {
    gap: 8px;
}

.rankor-catalog-agent {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 70, 85, 0.8), rgba(24, 229, 184, 0.8));
}

.rankor-catalog-preview-image,
.rankor-catalog-preview-panel {
    width: 100%;
    height: 58px;
    border-radius: 10px;
}

.rankor-catalog-preview-image {
    background: linear-gradient(135deg, rgba(255, 70, 85, 0.18), rgba(255, 255, 255, 0.05));
}

.rankor-catalog-preview-panel {
    background: rgba(10, 14, 19, 0.72);
}

.rankor-login-gate {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.rankor-login-card {
    width: min(100%, 520px);
    padding: 30px;
    border-radius: 18px;
    background: rgba(21, 30, 37, 0.84);
    border: 0;
    box-shadow: var(--rankor-shadow);
    text-align: center;
}

.rankor-login-title {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 12px;
}

.rankor-login-copy {
    color: var(--rankor-muted);
    margin-bottom: 18px;
    line-height: 1.6;
}

.rankor-overlay-shell {
    display: grid;
    place-items: center;
    padding: 0;
}

.rankor-overlay-stage-wrap {
    width: 100vw;
    height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.rankor-overlay-stage-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    min-height: 54px;
}

.rankor-overlay-meta {
    align-items: flex-start;
    text-align: left;
}

.rankor-overlay-title {
    color: var(--rankor-red);
}

.rankor-template-pill {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
}

.rankor-pill-note {
    font-size: 11px;
    color: var(--rankor-muted);
}

.rankor-helper-copy {
    margin-bottom: 12px;
    color: var(--rankor-muted);
    font-size: 12px;
    line-height: 1.5;
}

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

.rankor-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--rankor-text);
    padding: 10px 12px;
    cursor: pointer;
}

.rankor-choice.is-active {
    background: rgba(255, 70, 85, 0.18);
}

.rankor-choice-swatch {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    flex: 0 0 auto;
}

.rankor-color-input {
    width: 100%;
    height: 42px;
    padding: 4px;
    border: 0;
    border-radius: 10px;
    background: rgba(7, 10, 13, 0.82);
}

.rankor-swatch-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.rankor-color-dot {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 2px solid transparent;
    cursor: pointer;
}

.rankor-color-dot.is-active {
    border-color: rgba(255, 255, 255, 0.92);
}

.rankor-toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.rankor-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--rankor-muted);
    font-size: 13px;
    font-weight: 700;
}

.rankor-toggle input {
    accent-color: var(--rankor-red);
}

.rankor-toggle-block {
    align-items: center;
    min-height: 42px;
}

.rankor-bar-head.is-value-only {
    justify-content: flex-end;
}

.rankor-rank.is-icon-only {
    justify-content: flex-start;
}

.rankor-agent-card.has-copy .rankor-agent-icon {
    width: 40px;
    height: 40px;
}

body.rankor-mode-overlay .rankor-overlay-shell,
body.rankor-mode-overlay .rankor-overlay-stage-wrap,
body.rankor-mode-overlay .rankor-stage-shell,
body.rankor-mode-overlay .rankor-stage,
body.rankor-mode-overlay #rankor-app {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    border: 0;
}

body.rankor-mode-overlay .rankor-stage-shell {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
}

body.rankor-mode-overlay .rankor-stage::before {
    display: none;
}

@media (max-width: 1280px) {
    .rankor-layout {
        grid-template-columns: 1fr;
    }

    .rankor-sidebar,
    .rankor-inspector {
        order: 2;
    }

    .rankor-canvas-area {
        order: 1;
    }
}

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .rankor-topbar {
        grid-template-columns: 1fr;
    }

    .rankor-topbar-meta,
    .rankor-overlay-meta {
        align-items: flex-start;
        text-align: left;
    }

    .rankor-grid-two {
        grid-template-columns: 1fr;
    }

    .rankor-agent-grid {
        grid-template-columns: 1fr;
    }

    .rankor-topbar-actions {
        flex-wrap: wrap;
    }

    .rankor-stage-frame,
    .rankor-stage-shell {
        width: 100%;
        border-radius: 20px;
    }
}
