body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #0b1120;
    color: #e5e7eb;
}

header {
    padding: 12px 16px;
    border-bottom: 1px solid #1f2933;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

header h1 {
    margin: 0;
    font-size: 18px;
    flex: 1;
}

.guide-card {
    display: none;
    margin: 12px 16px 0;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #1e293b;
    background: linear-gradient(145deg, #0b1225 0%, #0b1120 100%);
    font-size: 13px;
    line-height: 1.6;
}

.guide-card.open {
    display: block;
}

.guide-card[hidden] {
    display: none !important;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    justify-content: flex-end;
}

.header-actions .pill {
    font-size: 12px;
}

.header-actions .lang-link {
    color: #93c5fd;
    text-decoration: none;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #1f2937;
    background: #0f172a;
}

.header-actions .lang-link:hover {
    text-decoration: underline;
}

.guide-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.guide-head h2 {
    margin: 0;
    font-size: 15px;
    color: #e5e7eb;
}

.guide-pill {
    border-radius: 999px;
    padding: 2px 10px;
    background: #0f172a;
    border: 1px solid #1f2937;
    color: #9ca3af;
    font-size: 12px;
}

.guide-steps {
    margin: 0 0 10px 18px;
    padding: 0;
}

.guide-steps li {
    margin: 0 0 6px;
    color: #cbd5f5;
}

.prompt-block {
    border: 1px dashed #1f2937;
    background: #0f172a;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.prompt-title {
    margin: 0 0 6px;
    font-size: 13px;
    color: #cbd5f5;
}

.prompt-text {
    margin: 0;
    white-space: pre-wrap;
    font-size: 13px;
    color: #e5e7eb;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.guide-notes {
    border-top: 1px solid #111827;
    padding-top: 8px;
}

.guide-notes ul {
    margin: 6px 0 0 18px;
    padding: 0;
}

.guide-notes li {
    margin-bottom: 4px;
    color: #9ca3af;
}

.container {
    display: flex;
    gap: 16px;
    padding: 12px 16px 20px;
    box-sizing: border-box;
}

.controls {
    width: 260px;
    flex-shrink: 0;
    background: #020617;
    border-radius: 10px;
    padding: 12px;
    border: 1px solid #1e293b;
    font-size: 13px;
}

.controls h2 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #e5e7eb;
}

.section {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #111827;
}

.section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section label {
    display: block;
    margin-bottom: 4px;
    color: #cbd5f5;
}

.section input[type="number"] {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #1f2937;
    background: #020617;
    color: #e5e7eb;
    outline: none;
    font-size: 13px;
}

.section input[type="number"]:focus {
    border-color: #3b82f6;
}

.section input[type="file"] {
    width: 100%;
    font-size: 13px;
}

.checkbox-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
}

.checkbox-row input[type="checkbox"] {
    accent-color: #3b82f6;
}

button {
    cursor: pointer;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 6px 10px;
    font-size: 13px;
    background: #3b82f6;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

button.secondary {
    background: transparent;
    color: #e5e7eb;
    border-color: #374151;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
    line-height: 1.4;
}

.canvas-wrapper {
    flex: 1;
    min-width: 0;
    background: #020617;
    border-radius: 10px;
    border: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
}

.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: #9ca3af;
}

.canvas-toolbar .pill {
    border-radius: 999px;
    padding: 2px 8px;
    background: #0f172a;
    border: 1px solid #1f2937;
}

canvas {
    width: 100%;
    max-height: calc(100vh - 120px);
    background: #020617;
    border-radius: 8px;
    border: 1px solid #111827;
    display: block;
}

.canvas-stage {
    position: relative;
    overflow: visible;
    margin-top: 6px;
}

.handle-layer {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    pointer-events: none;
}

.handle {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0ea5e9;
    border: 2px solid #e0f2fe;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    cursor: grab;
    pointer-events: auto;
}

.handle:active {
    cursor: grabbing;
}

.handle-vertical {
    top: -12px;
}

.handle-horizontal {
    left: -12px;
}

.legend {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: #9ca3af;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 10px;
    height: 2px;
    border-radius: 999px;
}

.legend-dot.vert {
    background: #f97316;
}

.legend-dot.hori {
    background: #22c55e;
}

.tile-panel {
    margin: 12px 0 0;
    background: #020617;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 12px;
}

.tiles-wrapper {
    margin-top: 10px;
}

.tile-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: #e5e7eb;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.tile-card {
    border: 1px solid #1f2937;
    border-radius: 8px;
    padding: 6px;
    background: #0f172a;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tile-card:hover {
    border-color: #3b82f6;
}

.tile-card.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.tile-thumb {
    width: 100%;
    height: 100px;
    background: #111827;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.tile-thumb img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.tile-meta {
    font-size: 12px;
    color: #cbd5f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    border-radius: 999px;
    padding: 2px 8px;
    background: #0f172a;
    border: 1px solid #1f2937;
    font-size: 11px;
    color: #9ca3af;
}

.tile-panel__actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.action-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

button.primary {
    background: #3b82f6;
    color: #fff;
    border-color: #2563eb;
}

@media (max-width: 880px) {
    .container {
        flex-direction: column;
    }

    .controls {
        width: 100%;
    }
}
