.tcct-page {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(242, 129, 54, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(15, 89, 76, 0.16), transparent 30%),
        linear-gradient(180deg, #f2efe8 0%, #e4ddd0 100%);
    color: #1d221f;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.tcct-page * {
    box-sizing: border-box;
}

.tcct-app {
    min-height: 100vh;
    padding: 24px;
}

.tcct-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 20px;
}

.tcct-eyebrow {
    margin: 0 0 8px;
    color: #9b3c13;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.tcct-header h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1;
}

.tcct-subtitle {
    margin: 10px 0 0;
    max-width: 840px;
    color: #4f5d55;
    font-size: 14px;
}

.tcct-status {
    min-height: 24px;
    margin-top: 12px;
    color: #214e44;
    font-size: 13px;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.tcct-status.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.tcct-status.is-error {
    color: #a12626;
}

.tcct-header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tcct-link,
.tcct-header-actions button,
.tcct-ghost {
    border: 1px solid #1d221f;
    background: #fffdf7;
    color: #1d221f;
    border-radius: 999px;
    padding: 10px 16px;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.tcct-header-actions button:hover,
.tcct-link:hover,
.tcct-ghost:hover {
    transform: translateY(-1px);
    background: #1d221f;
    color: #fffdf7;
}

.tcct-layout {
    display: grid;
    grid-template-areas: "sidebar workspace selection";
    grid-template-columns: 320px minmax(0, 1fr) minmax(300px, 340px);
    gap: 20px;
    align-items: start;
    justify-content: stretch;
    width: calc(100vw - 48px);
    max-width: calc(100vw - 48px);
}

.tcct-layout > * {
    min-width: 0;
}

.tcct-sidebar {
    grid-area: sidebar;
}

.tcct-workspace {
    grid-area: workspace;
}

.tcct-selection {
    grid-area: selection;
}

.tcct-panel {
    border: 1px solid rgba(29, 34, 31, 0.12);
    border-radius: 24px;
    background: rgba(255, 253, 247, 0.88);
    box-shadow: 0 18px 50px rgba(68, 56, 35, 0.08);
    backdrop-filter: blur(8px);
    padding: 18px;
}

.tcct-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.tcct-panel-head h2 {
    margin: 0;
    font-size: 18px;
}

.tcct-panel-head span {
    color: #627066;
    font-size: 13px;
}

.tcct-field {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.tcct-field span {
    color: #516157;
    font-size: 12px;
    font-weight: 600;
}

.tcct-field input {
    width: 100%;
    border: 1px solid rgba(29, 34, 31, 0.18);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fffdf7;
    color: #1d221f;
    font: inherit;
}

.tcct-filter-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.tcct-filter {
    border: 1px solid rgba(29, 34, 31, 0.16);
    background: #ece5d5;
    color: #2e3b34;
    border-radius: 999px;
    padding: 8px 12px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.tcct-filter.is-active {
    background: #0f594c;
    border-color: #0f594c;
    color: #f7f4ec;
}

.tcct-tool-list,
.tcct-selected-list {
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 260px);
    overflow: auto;
    padding-right: 4px;
}

.tcct-tool-card,
.tcct-selected-card {
    border: 1px solid rgba(29, 34, 31, 0.14);
    border-radius: 16px;
    background: #fffdfa;
    padding: 12px;
}

.tcct-selected-card.has-error {
    border-color: #cf2f2f;
    box-shadow: inset 0 0 0 1px rgba(207, 47, 47, 0.22);
}

.tcct-tool-card {
    display: grid;
    gap: 8px;
}

.tcct-tool-card h3,
.tcct-selected-card h3 {
    margin: 0;
    font-size: 14px;
    line-height: 1.3;
}

.tcct-tool-meta,
.tcct-selected-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tcct-chip {
    border-radius: 999px;
    background: #efe7d9;
    color: #46564d;
    padding: 4px 8px;
    font-size: 11px;
}

.tcct-tool-card button,
.tcct-selected-actions button {
    border: 0;
    background: #9b3c13;
    color: #fff9f1;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    cursor: pointer;
}

.tcct-tool-card button:hover,
.tcct-selected-actions button:hover {
    background: #792f10;
}

.tcct-workspace {
    display: grid;
    gap: 20px;
    min-width: 0;
    width: 100%;
    max-width: 900px;
    justify-self: center;
}

.tcct-canvas-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    border-radius: 22px;
    background: linear-gradient(180deg, #d4ccb8 0%, #c8bea7 100%);
    overflow: auto;
}

.tcct-case {
    position: relative;
    flex: 0 0 auto;
    width: min(100%, 900px);
    max-width: 100%;
    aspect-ratio: 455 / 305;
    border: 2px solid #1d221f;
    border-radius: 20px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent),
        linear-gradient(180deg, #36423d 0%, #28312d 100%);
    box-shadow:
        inset 0 0 0 6px rgba(255, 248, 231, 0.04),
        0 24px 50px rgba(36, 30, 23, 0.22);
}

.tcct-case-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: calc(100% / 18.2) calc(100% / 12.2);
    pointer-events: none;
}

.tcct-items-layer {
    position: absolute;
    inset: 0;
}

.tcct-guide-line {
    position: absolute;
    pointer-events: none;
    z-index: 30;
    background: rgba(81, 199, 223, 0.95);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.tcct-guide-line.vertical {
    top: 0;
    bottom: 0;
    width: 1.5px;
}

.tcct-guide-line.horizontal {
    left: 0;
    right: 0;
    height: 1.5px;
}

.tcct-case-item {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    appearance: none;
    -webkit-appearance: none;
    padding: 4px;
    border: 1.5px solid transparent;
    border-radius: 10px;
    background:
        linear-gradient(135deg, rgba(242, 129, 54, 0.16), rgba(15, 89, 76, 0.18)),
        rgba(249, 246, 239, 0.92);
    color: #132018;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    overflow: hidden;
    user-select: none;
    cursor: grab;
    touch-action: none;
    pointer-events: none;
    transform-origin: center center;
    will-change: transform;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.tcct-case-item.has-image {
    padding: 0;
    border: 1.5px solid transparent;
    border-radius: 8px;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    outline: none;
    overflow: visible;
}

.tcct-case-item.is-selected {
    border-color: transparent;
    box-shadow: none;
}

.tcct-case-item.has-image.is-selected {
    border-color: transparent;
    box-shadow: none;
}

.tcct-case-item.is-dragging {
    cursor: grabbing;
    z-index: 20;
}

.tcct-case-item.has-error {
    border-color: #cf2f2f;
    box-shadow: 0 0 0 3px rgba(207, 47, 47, 0.18);
}

.tcct-case-item.has-image.has-error {
    border-color: transparent;
    box-shadow: none;
}

.tcct-case-item.has-warning {
    border-color: #d89a1e;
    box-shadow: 0 0 0 2px rgba(216, 154, 30, 0.18);
}

.tcct-case-item.has-image.has-warning {
    border-color: transparent;
    box-shadow: none;
}

.tcct-item-outline-stage {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 9;
}

.tcct-item-hit-stage {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

.tcct-item-sprite-frame {
    position: absolute;
    inset: 0;
    display: block;
    pointer-events: none;
    overflow: visible;
    transform-origin: center center;
    z-index: 8;
}

.tcct-item-content-anchor {
    position: absolute;
    inset: 0;
    display: block;
    pointer-events: none;
    overflow: visible;
    transform-origin: center center;
}

.tcct-item-outline-svg {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.tcct-item-hit-svg {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.tcct-item-hit-path {
    fill: rgba(0, 0, 0, 0.001);
    stroke: none;
    pointer-events: fill;
    cursor: grab;
}

.tcct-item-outline-path {
    fill: none;
    stroke: rgba(255, 196, 68, 0.98);
    stroke-linejoin: round;
    stroke-linecap: round;
    filter: drop-shadow(0 0 2px rgba(255, 188, 66, 0.22));
}

.tcct-item-outline-svg.is-error .tcct-item-outline-path {
    stroke: rgba(207, 47, 47, 0.98);
    filter: drop-shadow(0 0 2px rgba(207, 47, 47, 0.2));
}

.tcct-item-image-stage {
    position: absolute;
    overflow: visible;
    background: transparent;
    pointer-events: none;
}

.tcct-case-item .tcct-item-label {
    position: absolute;
    left: 6px;
    right: auto;
    bottom: 4px;
    max-width: calc(100% - 12px);
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(12, 17, 15, 0.46);
    color: #fff;
    font-size: 10px;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    word-break: break-word;
    pointer-events: none;
}

.tcct-case-item .tcct-item-label.is-image-label {
    left: 4px;
    bottom: 4px;
    max-width: calc(100% - 8px);
    padding: 1px 5px;
    background: rgba(12, 17, 15, 0.34);
    font-size: 9px;
    line-height: 1.1;
}

.tcct-item-image {
    position: absolute;
    display: block;
    max-width: none;
    max-height: none;
    object-fit: contain;
    background: transparent !important;
    pointer-events: none;
    transform-origin: center center;
    transform: rotate(0deg);
}

.tcct-hint {
    margin: 14px 0 0;
    color: #5f6a64;
    font-size: 13px;
}

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

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

.tcct-debug-item {
    border-radius: 14px;
    padding: 12px;
    background: #f6efe2;
    border: 1px solid rgba(29, 34, 31, 0.12);
}

.tcct-debug-label {
    margin: 0 0 6px;
    color: #55635a;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tcct-debug-value {
    margin: 0;
    color: #1d221f;
    font-size: 13px;
    font-weight: 700;
    word-break: break-word;
}

.tcct-debug-errors {
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
}

.tcct-debug-error {
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(161, 38, 38, 0.08);
    border: 1px solid rgba(161, 38, 38, 0.22);
    color: #7e1f1f;
    font-size: 12px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.tcct-stat {
    border-radius: 18px;
    padding: 14px;
    background: #efe6d7;
}

.tcct-stat-label {
    margin: 0 0 8px;
    color: #536359;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tcct-stat-value {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.tcct-selected-card {
    display: grid;
    gap: 10px;
}

.tcct-selected-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    font-size: 12px;
    color: #415249;
}

.tcct-selected-grid strong {
    color: #1d221f;
}

.tcct-selected-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tcct-sidebar,
.tcct-selection,
.tcct-panel,
.tcct-selected-card,
.tcct-selected-grid,
.tcct-debug-grid,
.tcct-debug-errors,
.tcct-stats-grid {
    min-width: 0;
}

.tcct-selected-actions .tcct-danger {
    background: #a12626;
}

.tcct-selected-actions .tcct-danger:hover {
    background: #871d1d;
}

.tcct-empty {
    padding: 20px 12px;
    border: 1px dashed rgba(29, 34, 31, 0.18);
    border-radius: 16px;
    color: #617067;
    text-align: center;
    background: rgba(255, 253, 247, 0.64);
}

@media (max-width: 1180px) {
    .tcct-layout {
        grid-template-areas:
            "sidebar workspace"
            "selection selection";
        grid-template-columns: 320px minmax(0, 1fr);
        justify-content: start;
    }

    .tcct-workspace {
        max-width: 900px;
    }

    .tcct-selection {
        grid-column: 1 / -1;
    }

    .tcct-selected-list {
        max-height: none;
    }
}

@media (max-width: 1120px) {
    .tcct-layout {
        grid-template-areas:
            "workspace"
            "selection"
            "sidebar";
        grid-template-columns: minmax(0, 1fr);
        justify-content: center;
    }

    .tcct-sidebar,
    .tcct-workspace,
    .tcct-selection {
        grid-column: 1 / -1;
    }

    .tcct-workspace {
        width: 100%;
        max-width: 900px;
    }
}

@media (max-width: 920px) {
    .tcct-app {
        padding: 16px;
    }

    .tcct-header,
    .tcct-layout {
        grid-template-columns: 1fr;
        display: grid;
        justify-content: stretch;
    }

    .tcct-header-actions {
        justify-content: flex-start;
    }

    .tcct-workspace {
        width: 100%;
        max-width: none;
    }

    .tcct-case {
        width: min(100%, 900px);
        max-width: 100%;
    }

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

    .tcct-tool-list,
    .tcct-selected-list {
        max-height: none;
    }
}
