body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    background: radial-gradient(circle at top, #131a2f 0%, #080b17 60%, #05070f 100%);
    color: #cbd5e1;
}

header {
    background: linear-gradient(135deg, rgba(30, 37, 56, 0.95), rgba(24, 33, 52, 0.92));
    border-bottom: 1px solid rgba(120, 144, 180, 0.3);
    color: #f1f5f9;
    padding: 24px;
    text-align: center;
    box-shadow: 0 12px 28px rgba(6, 10, 21, 0.55);
}

header h1 {
    margin: 0;
    font-size: 28px;
    letter-spacing: 0.08em;
}

header p {
    margin: 8px 0 0;
    font-size: 16px;
    color: rgba(203, 213, 225, 0.75);
}

main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
}

.panel {
    background: rgba(13, 17, 28, 0.86);
    border: 1px solid rgba(72, 88, 118, 0.35);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 18px 40px rgba(4, 8, 18, 0.6);
    backdrop-filter: blur(8px);
}

.panel h2, .panel h3, .panel h4 {
    margin-top: 0;
    color: #38bdf8;
}

textarea#verilog-input {
    width: 100%;
    height: 240px;
    padding: 16px;
    background: rgba(9, 13, 24, 0.92);
    color: #e2e8f0;
    border: 1px solid rgba(88, 104, 140, 0.45);
    border-radius: 12px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 14px;
    resize: vertical;
}

input[type="text"],
input[type="password"],
select {
    padding: 12px 14px;
    background: rgba(9, 13, 24, 0.92);
    color: #e2e8f0;
    border: 1px solid rgba(88, 104, 140, 0.45);
    border-radius: 12px;
    font-size: 14px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button.primary {
    background: linear-gradient(120deg, #1f6feb, #3a9efd);
    color: #f8fafc;
    box-shadow: 0 8px 22px rgba(31, 111, 235, 0.35);
}

button.accent {
    background: linear-gradient(120deg, #6f5bd1, #8f7dee);
    color: #f8fafc;
    box-shadow: 0 8px 22px rgba(111, 91, 209, 0.35);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
}

/* 日志容器样式 */
.log-container {
    background: rgba(9, 13, 24, 0.92);
    border: 1px solid rgba(72, 88, 118, 0.35);
    border-radius: 12px;
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 13px;
}

.log-entry {
    padding: 6px 12px;
    margin: 4px 0;
    border-radius: 6px;
    border-left: 4px solid;
    word-wrap: break-word;
}

.log-entry.info {
    background: rgba(59, 130, 246, 0.15);
    border-left-color: #3b82f6;
    color: #93c5fd;
}

.log-entry.success {
    background: rgba(34, 197, 94, 0.15);
    border-left-color: #22c55e;
    color: #86efac;
}

.log-entry.warning {
    background: rgba(245, 158, 11, 0.15);
    border-left-color: #f59e0b;
    color: #fbbf24;
}

.log-entry.error {
    background: rgba(239, 68, 68, 0.15);
    border-left-color: #ef4444;
    color: #fca5a5;
}

/* 折叠按钮样式 */
.toggle-btn {
    font-size: 11px;
    padding: 4px 8px;
    margin-left: 8px;
    background: rgba(96, 118, 168, 0.3);
    border: 1px solid rgba(96, 118, 168, 0.5);
    border-radius: 4px;
    color: #cbd5e1;
    cursor: pointer;
    transition: background 0.2s ease;
}

.toggle-btn:hover {
    background: rgba(96, 118, 168, 0.5);
}

/* 可折叠代码块 */
.code-block.collapsible.collapsed {
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.code-block.collapsible.collapsed::after {
    content: "...";
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(9, 13, 24, 0.95);
    padding: 4px 8px;
    color: #94a3b8;
    border-radius: 4px 0 0 0;
}

.status {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(60, 78, 119, 0.25);
    border: 1px solid rgba(96, 118, 168, 0.4);
    min-height: 40px;
}

.panel.results {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.panel.results .column {
    flex: 1 1 360px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-block, .code-block {
    background: rgba(9, 13, 24, 0.92);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(72, 88, 118, 0.35);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 160px;
}

.split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(9, 13, 24, 0.92);
    border-radius: 12px;
    overflow: hidden;
}

table th, table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(72, 88, 118, 0.35);
    text-align: center;
}

table th {
    background: rgba(18, 24, 40, 0.9);
    color: #a5b4fc;
}

table tr:last-child td {
    border-bottom: none;
}

/* ─── Circuit Links ─── */
.circuit-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.circuit-link {
    flex: 1 1 240px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px;
    background: rgba(15, 20, 35, 0.92);
    border: 1px solid rgba(72, 88, 118, 0.35);
    border-radius: 14px;
    text-decoration: none;
    color: #e2e8f0;
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
}

.circuit-link:hover {
    border-color: #38bdf8;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.15);
    transform: translateY(-2px);
}

.circuit-link .link-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 17px;
    background: rgba(56, 189, 248, 0.1);
    border: 2px solid rgba(56, 189, 248, 0.25);
    color: #38bdf8;
    flex-shrink: 0;
}

.circuit-link .link-text {
    font-weight: 600;
    font-size: 15px;
}

.circuit-link.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.circuit-hint {
    text-align: center;
    font-size: 12px;
    color: rgba(148, 163, 184, 0.5);
    margin-top: 8px;
}

footer {
    text-align: center;
    padding: 16px;
    color: rgba(148, 163, 184, 0.6);
}

/* ─── Agent Pipeline ─── */
.pipeline-wrap {
    position: relative;
    padding: 24px 0 12px;
}

.pipeline-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    position: relative;
    z-index: 2;
}

/* ── Node ── */
.agent-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 18px 12px;
    background: rgba(15, 20, 35, 0.92);
    border: 2px solid rgba(72, 88, 118, 0.3);
    border-radius: 14px;
    min-width: 108px;
    transition: border-color 0.5s, box-shadow 0.5s, transform 0.4s;
}

.node-ring {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 17px;
    background: rgba(56, 189, 248, 0.1);
    border: 2px solid rgba(56, 189, 248, 0.25);
    color: #38bdf8;
    transition: all 0.5s;
}

.node-label {
    font-weight: 600;
    font-size: 13px;
    color: #e2e8f0;
}

.node-sub {
    font-size: 11px;
    color: rgba(148, 163, 184, 0.7);
}

.node-status {
    font-size: 11px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    color: rgba(148, 163, 184, 0.5);
    min-height: 16px;
    transition: color 0.3s;
}

/* Active state */
.agent-node.active {
    border-color: #38bdf8;
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.2), 0 0 56px rgba(56, 189, 248, 0.06);
    transform: translateY(-3px);
}

.agent-node.active .node-ring {
    background: rgba(56, 189, 248, 0.25);
    border-color: #38bdf8;
    animation: ring-pulse 2s ease-in-out infinite;
}

.agent-node.active .node-status {
    color: #7dd3fc;
}

/* Done state */
.agent-node.done {
    border-color: rgba(34, 197, 94, 0.5);
}

.agent-node.done .node-ring {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.55);
    color: #4ade80;
    animation: none;
}

.agent-node.done .node-status {
    color: #86efac;
}

@keyframes ring-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.35); }
    50%      { box-shadow: 0 0 14px 4px rgba(56, 189, 248, 0.5); }
}

/* ── Pipe (connector) ── */
.pipe {
    width: 52px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.pipe-track {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: rgba(72, 88, 118, 0.3);
    position: relative;
    overflow: hidden;
}

.pipe-dot {
    position: absolute;
    top: -2px;
    left: -14px;
    width: 14px;
    height: 7px;
    border-radius: 4px;
    background: transparent;
    transition: background 0.3s;
}

.pipe.active .pipe-track {
    background: rgba(56, 189, 248, 0.35);
}

.pipe.active .pipe-dot {
    background: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
    animation: dot-flow 0.9s ease-in-out infinite;
}

@keyframes dot-flow {
    0%   { left: -14px; opacity: 0; }
    15%  { opacity: 1; }
    85%  { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}

/* ── Feedback arc ── */
.feedback-arc {
    margin: 0 auto;
    width: 78%;
    height: 28px;
    border: 2px dashed rgba(139, 92, 246, 0.2);
    border-top: none;
    border-radius: 0 0 14px 14px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    opacity: 0;
    transition: opacity 0.5s, border-color 0.5s;
}

.feedback-arc.active {
    opacity: 1;
    border-color: rgba(139, 92, 246, 0.55);
    animation: arc-glow 3s ease-in-out infinite;
}

@keyframes arc-glow {
    0%, 100% { border-color: rgba(139, 92, 246, 0.35); }
    50%      { border-color: rgba(139, 92, 246, 0.7); }
}

.feedback-text {
    font-size: 11px;
    color: rgba(167, 139, 250, 0.85);
    background: rgba(13, 17, 28, 0.95);
    padding: 0 10px;
    position: relative;
    top: 8px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    main {
        padding: 16px;
    }
    .panel {
        padding: 20px;
    }
}
