body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    /* padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
}

main {
    box-sizing: border-box;
    background: white;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 1400px;
    height: 100vh;
    margin: 0 auto;
}

.hidden{
    display: none !important;
}

.horizontal{
    display: flex;
    gap: 10px;
}
.horizontal > *{
    flex: 1;
    display: flex;
    flex-direction: column;
}

.top-controls {
    flex-shrink: 0;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e1e5e9;
}

.temperature-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.temperature-control input[type="range"] {
    flex: 1;
}

.temperature-control span {
    min-width: 40px;
    font-weight: 600;
    text-align: center;
}

.main-content {
    display: flex;
    gap: 20px;
    flex: 1;
    overflow: hidden;
}

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.right-panel {
    flex: 1;
    min-width: 500px;
    display: flex;
    flex-direction: column;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 15px;
    font-size: 24px;
}

.description {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.input-section {
    margin-bottom: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

#apiKey {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

#modelSelect {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 15px;
    flex-shrink: 0;
    background: white;
    cursor: pointer;
}

#modelSelect:focus {
    border-color: #667eea;
    outline: none;
}

#input, #output {
    flex: 1;
    /* min-height: 200px; */
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    resize: none;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 15px;
    flex-shrink: 0;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.loading {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.error {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
    border-left: 4px solid #c33;
}

#logits {
    margin-top: 0;
    overflow-y: scroll;
    flex: 1;
    padding-right: 10px;
}

.logit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 4px 0;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
    font-size: 14px;
}

.logit-item.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.logit-item.clickable:hover {
    background: #e3f2fd;
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    border-left-color: #4fc3f7;
}

.logit-item.clickable:active {
    transform: translateX(1px);
    background: #bbdefb;
}

.logit-left {
    display: flex;
    align-items: center;
    flex: 1;
}

.logit-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logit-rank {
    background: #667eea;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    margin-right: 10px;
    flex-shrink: 0;
}

.logit-token {
    font-weight: 600;
    color: #333;
    font-family: 'Courier New', monospace;
    background: #e9ecef;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.special-char {
    background: #ffeb3b;
    color: #e65100;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    margin: 0 1px;
    display: inline-block;
}

.logit-item.selected {
    background: #e8f5e8;
    border-left-color: #4caf50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.logit-item.selected:hover {
    background: #dcedc8;
}

.selected-rank {
    background: #4caf50 !important;
}

.selected-indicator {
    font-size: 10px;
    color: #4caf50;
    font-weight: 600;
    margin-top: 2px;
}

.probability-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.probability-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bar-label {
    font-size: 10px;
    color: #666;
    min-width: 35px;
    font-weight: 600;
}

.probability-bar-container {
    width: 60px;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.probability-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease;
}

.raw-bar {
    background: linear-gradient(90deg, #4caf50, #8bc34a, #cddc39, #ffeb3b, #ffc107, #ff9800, #ff5722);
}

.temp-bar {
    background: linear-gradient(90deg, #2196f3, #03a9f4, #00bcd4, #009688, #4caf50, #8bc34a, #cddc39);
}

.probability-text {
    font-size: 10px;
    color: #555;
    font-weight: 600;
    min-width: 35px;
    text-align: right;
}

.logit-value {
    color: #667eea;
    font-weight: 600;
    font-size: 12px;
    min-width: 60px;
    text-align: right;
}

.token-container{
    display: flex;
    flex-wrap: wrap;
}

.token{
    display: inline-block;
    padding: 4px 8px;
    margin: 0 4px 4px 0;
    border-radius: 8px;
    border: 1px solid rgba(34,34,34,0.06);
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.6);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.3;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
    position: relative;
    cursor: pointer;
}

.token:hover{
    font-weight: 900;
    transform: translateY(-1px) scale(1.1);
    box-shadow: 0 6px 18px rgba(102,126,234,0.12), inset 0 -2px 0 rgba(0,0,0,0.03);
    border-color: rgba(102,126,234,0.35);
    z-index: 3;
}

.tippy-content .selected-token {
    font-weight: 700;
    color: #00c34b; /* stronger green when selected */
}

.tippy-content ol{
    margin: 0;
    padding-left: 2em;
}



/* Alternating subtle backgrounds so token boundaries are visually clear.
   These are intentionally low-contrast and repeat every 8 tokens. */
.token:nth-child(8n+1){ background: #e3f2fd; border-color: rgba(3, 100, 180, 0.08); }
.token:nth-child(8n+2){ background: #f3e5f5; border-color: rgba(123, 31, 162, 0.08); }
.token:nth-child(8n+3){ background: #fff3e0; border-color: rgba(255, 140, 0, 0.08); }
.token:nth-child(8n+4){ background: #e8f5e9; border-color: rgba(46, 125, 50, 0.08); }
.token:nth-child(8n+5){ background: #e1f5fe; border-color: rgba(1, 143, 174, 0.08); }
.token:nth-child(8n+6){ background: #fff0f6; border-color: rgba(194, 24, 91, 0.08); }
.token:nth-child(8n+7){ background: #f9fff6; border-color: rgba(101, 191, 85, 0.08); }
.token:nth-child(8n+8){ background: #eef2ff; border-color: rgba(64, 80, 170, 0.08); }
/* Accessibility: focus styles for keyboard navigation */
.token:focus{
    outline: 3px solid rgba(102,126,234,0.18);
    outline-offset: 2px;
}

.token-tooltip ol {
    margin: 0;
}
.token-tooltip li {
    white-space: nowrap;
}