:root {
    --bg-0: #020210;
    --bg-1: #060615;
    --bg-2: #0a0a1a;
    --accent: #00e0ff;
    --accent-2: #00c8ff;
    --accent-soft: #55eeff;
    --accent-alt: #7b4fff;
    --pink: #ff2b8a;
    --green: #00ff88;
    --yellow: #ffcc00;
    --red: #ff5555;
    --white: #f0f0f5;
    --mute: #a0a0b8;
    --line: rgba(255,255,255,.08);
    --line-accent: rgba(0,224,255,.22);
    --glass: rgba(8,8,22,.6);
    --neon: 0 0 10px rgba(0,224,255,.9),0 0 28px rgba(0,224,255,.5),0 0 60px rgba(0,224,255,.25);
    --neon-soft: 0 0 6px rgba(0,210,255,.7),0 0 20px rgba(0,210,255,.35);
    --font-jp: 'Noto Sans JP',system-ui,sans-serif;
    --font-mono: 'JetBrains Mono',monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    background: var(--bg-0);
    color: var(--white);
    font-family: var(--font-jp);
    overflow-x: hidden;
    height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

body {
    display: flex;
    flex-direction: column;
}

.bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(0,224,255,.04) 1px,transparent 1px),linear-gradient(90deg,rgba(0,224,255,.04) 1px,transparent 1px);
    background-size: 60px 60px;
    opacity: .35;
}

.bg-scanline {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(to bottom,rgba(255,255,255,.015) 0 1px,transparent 1px 3px);
    mix-blend-mode: overlay;
    opacity: .4;
}

header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line-accent);
    background: rgba(2,2,16,.5);
    backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
}

h1 {
    font-family: var(--font-mono);
    font-size: 20px;
    letter-spacing: .1em;
    color: var(--accent);
    text-shadow: var(--neon-soft);
}

.header-actions {
    display: flex;
    gap: 8px;
}

main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 360px;
    grid-template-rows: 1fr auto;
    grid-template-areas:
        "actions tokens"
        "log tokens";
    gap: 14px;
    padding: 14px;
    overflow: hidden;
    min-height: 0;
}

.actions-area {
    grid-area: actions;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    min-height: 0;
}

.tokens-area {
    grid-area: tokens;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.tokens-area .panel {
    flex: 1;
}

.log-area {
    grid-area: log;
    display: flex;
    flex-direction: column;
    max-height: 220px;
    min-height: 160px;
}

.log-area .panel {
    max-height: 100%;
}

.panel {
    background: var(--glass);
    border: 1px solid var(--line-accent);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-title {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: .15em;
    color: var(--accent);
    margin-bottom: 12px;
    text-transform: uppercase;
    opacity: .9;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.panel-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--accent);
}

.panel-title .badge {
    margin-left: auto;
    font-size: 11px;
    background: rgba(0,224,255,.15);
    border: 1px solid var(--line-accent);
    border-radius: 12px;
    padding: 2px 10px;
    color: var(--accent);
    letter-spacing: 0;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
    background: rgba(0,60,120,.25);
    border: 1px solid var(--line-accent);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: all .2s;
    width: 100%;
}

input:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 14px rgba(0,224,255,.35);
    background: rgba(0,70,140,.3);
}

input::placeholder,
textarea::placeholder {
    color: rgba(0,200,255,.45);
    font-size: 12px;
}

button {
    background: rgba(0,224,255,.12);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 10px 16px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: .05em;
    cursor: pointer;
    transition: all .2s;
    text-transform: uppercase;
    white-space: nowrap;
    touch-action: manipulation;
}

button:hover {
    background: rgba(0,224,255,.25);
    box-shadow: 0 0 14px rgba(0,224,255,.45);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button.danger {
    background: rgba(255,43,138,.15);
    border-color: var(--pink);
    color: var(--pink);
}

button.danger:hover {
    background: rgba(255,43,138,.3);
    box-shadow: 0 0 14px rgba(255,43,138,.4);
}

button.success {
    background: rgba(0,255,136,.15);
    border-color: var(--green);
    color: var(--green);
}

button.success:hover {
    background: rgba(0,255,136,.3);
    box-shadow: 0 0 14px rgba(0,255,136,.4);
}

button.secondary {
    background: rgba(123,79,255,.15);
    border-color: var(--accent-alt);
    color: var(--accent-alt);
}

button.secondary:hover {
    background: rgba(123,79,255,.3);
    box-shadow: 0 0 14px rgba(123,79,255,.4);
}

a.accent-link {
    background: rgba(0,224,255,.12);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 14px 20px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 14px;
    letter-spacing: .05em;
    cursor: pointer;
    transition: all .2s;
    text-transform: uppercase;
    white-space: nowrap;
    touch-action: manipulation;
    line-height: 1;
}

a.accent-link:hover {
    background: rgba(0,224,255,.25);
    box-shadow: 0 0 14px rgba(0,224,255,.45);
    transform: translateY(-1px);
}

.btn-full {
    width: 100%;
}

.btn-lg {
    padding: 14px 20px;
    font-size: 14px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.action-card {
    background: rgba(0,50,100,.2);
    border: 1px solid var(--line-accent);
    border-radius: 10px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all .2s;
}

.action-card:hover {
    border-color: rgba(0,224,255,.4);
    background: rgba(0,60,120,.25);
}

.action-card-title {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: .12em;
    color: var(--accent-soft);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-card-title::before {
    content: '›';
    color: var(--accent);
    font-size: 16px;
    font-weight: 700;
}

.action-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-card input,
.action-card textarea {
    font-size: 13px;
}

.action-card textarea {
    resize: vertical;
    min-height: 60px;
}

.action-card .input-row {
    display: flex;
    gap: 8px;
}

.action-card .input-row input {
    flex: 1;
}

.action-card .input-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.action-card .input-col input {
    width: 100%;
}

.action-card .input-hint {
    font-size: 10px;
    color: var(--accent);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .8;
    margin-bottom: 2px;
}

.action-card .input-unit {
    font-size: 10px;
    color: var(--mute);
    font-family: var(--font-mono);
    opacity: .7;
    margin-top: 1px;
}

.token-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.token-tab {
    flex: 1;
    padding: 8px;
    font-size: 11px;
    text-align: center;
    background: rgba(0,60,120,.2);
    border: 1px solid var(--line-accent);
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s;
    color: var(--mute);
    font-family: var(--font-mono);
    text-transform: uppercase;
    user-select: none;
}

.token-tab.active {
    background: rgba(0,224,255,.2);
    border-color: var(--accent);
    color: var(--accent);
}

.token-tab:hover:not(.active) {
    background: rgba(0,60,120,.35);
}

.token-input-area {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.token-input-area.active {
    display: flex;
}

.token-input-area textarea {
    min-height: 100px;
    resize: vertical;
    font-size: 12px;
    line-height: 1.8;
}

.token-input-area .btn-row {
    display: flex;
    gap: 8px;
}

.token-input-area .btn-row button {
    flex: 1;
}

.token-list {
    background: rgba(0,50,100,.15);
    border: 1px solid rgba(0,224,255,.1);
    border-radius: 6px;
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    font-size: 12px;
}

.token-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(0,40,80,.3);
    border: 1px solid rgba(0,224,255,.1);
    border-radius: 6px;
    margin-bottom: 8px;
    color: var(--mute);
    font-size: 12px;
    transition: all .2s;
    gap: 8px;
}

.token-item:last-child {
    margin-bottom: 0;
}

.token-item:hover {
    border-color: var(--line-accent);
    background: rgba(0,50,100,.4);
}

.token-item-text {
    flex: 1;
    word-break: break-all;
    color: var(--accent-soft);
    font-family: var(--font-mono);
}

.token-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.token-item-actions button {
    padding: 4px 8px;
    font-size: 10px;
}

.token-empty {
    text-align: center;
    color: var(--mute);
    padding: 20px;
    font-size: 12px;
    opacity: .6;
}

.user-info-mini {
    background: rgba(0,50,100,.2);
    border: 1px solid rgba(0,224,255,.15);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.8;
    color: var(--mute);
    margin-top: 10px;
    flex-shrink: 0;
}

.user-info-mini .row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info-mini .label {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 10px;
}

.user-info-mini .value {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--white);
    word-break: break-all;
    text-align: right;
    max-width: 60%;
}

.log-panel {
    max-height: 100%;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.log-filter {
    display: flex;
    gap: 4px;
}

.log-filter button {
    padding: 3px 8px;
    font-size: 10px;
    opacity: .5;
    border-radius: 4px;
}

.log-filter button.active {
    opacity: 1;
    background: rgba(0,224,255,.2);
}

#logOutput {
    flex: 1;
    background: rgba(0,10,20,.8);
    border: 1px solid rgba(0,224,255,.15);
    border-radius: 6px;
    padding: 8px 10px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    color: var(--accent);
    min-height: 0;
}

.log-entry {
    margin-bottom: 2px;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,.03);
    animation: fadeIn .2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-4px); }
    to { opacity: 1; transform: translateX(0); }
}

.log-time {
    color: var(--accent-alt);
    opacity: .6;
    margin-right: 4px;
    font-size: 10px;
}

.log-tag {
    display: inline-block;
    padding: 0 4px;
    border-radius: 3px;
    font-size: 9px;
    margin-right: 4px;
    font-weight: 700;
}

.log-entry.success { color: var(--green); }
.log-entry.success .log-tag { background: rgba(0,255,136,.12); }
.log-entry.error { color: var(--red); }
.log-entry.error .log-tag { background: rgba(255,85,85,.12); }
.log-entry.warning { color: var(--yellow); }
.log-entry.warning .log-tag { background: rgba(255,204,0,.12); }
.log-entry.info .log-tag { background: rgba(0,224,255,.12); }

.stats-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: rgba(0,50,100,.2);
    border: 1px solid var(--line-accent);
    border-radius: 8px;
    flex-shrink: 0;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.stat-label {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--font-mono);
    color: var(--white);
    font-weight: 700;
    font-size: 13px;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-1);
    border: 1px solid var(--line-accent);
    border-radius: 10px;
    padding: 24px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 0 40px rgba(0,0,0,.5), 0 0 80px rgba(0,224,255,.1);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-title {
    font-family: var(--font-mono);
    font-size: 16px;
    letter-spacing: .1em;
    color: var(--accent);
    margin-bottom: 16px;
    text-transform: uppercase;
}

.modal-input {
    width: 100%;
    margin-bottom: 12px;
}

.modal-input:last-of-type {
    margin-bottom: 16px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-buttons button {
    flex: 1;
    padding: 10px;
}

.toast-container {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 90vw;
}

.toast {
    background: var(--bg-1);
    border: 1px solid var(--line-accent);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--white);
    box-shadow: 0 4px 20px rgba(0,0,0,.4);
    animation: slideIn .3s ease;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    word-break: break-word;
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }
.toast.warning { border-color: var(--yellow); color: var(--yellow); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0,224,255,.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0,224,255,.25);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0,224,255,.45);
}

@media (max-width: 900px) {
    html, body {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
    }

    body {
        display: block;
    }

    main {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "actions"
            "tokens"
            "log";
        overflow: visible;
        min-height: auto;
    }

    .actions-area {
        overflow: visible;
        min-height: auto;
    }

    .tokens-area {
        overflow: visible;
        min-height: auto;
    }

    .tokens-area .panel {
        flex: none;
    }

    .log-area {
        max-height: 180px;
        min-height: 120px;
    }

    h1 {
        font-size: 16px;
    }

    .action-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .action-card {
        padding: 14px;
    }

    .token-list {
        max-height: 200px;
        min-height: 80px;
    }

    #logOutput {
        min-height: 80px;
    }
}

@media (max-width: 600px) {
    header {
        padding: 10px 14px;
        gap: 8px;
        flex-wrap: wrap;
    }

    h1 {
        font-size: 13px;
        letter-spacing: .05em;
    }

    .header-actions button {
        padding: 6px 10px;
        font-size: 10px;
    }

    main {
        padding: 10px;
        gap: 10px;
    }

    .panel {
        padding: 12px;
        border-radius: 8px;
    }

    .panel-title {
        font-size: 11px;
    }

    .action-card {
        padding: 12px;
        gap: 10px;
        border-radius: 8px;
    }

    .action-card-title {
        font-size: 12px;
    }

    button, a.accent-link {
        padding: 10px 12px;
        font-size: 12px;
    }

    .btn-lg, a.accent-link.btn-lg {
        padding: 12px 14px;
        font-size: 12px;
    }

    input, textarea {
        font-size: 16px;
        padding: 10px;
    }

    .modal {
        padding: 10px;
    }

    .modal-content {
        padding: 16px;
        border-radius: 8px;
        max-height: 85vh;
    }

    .modal-title {
        font-size: 14px;
    }

    .modal-buttons button {
        padding: 10px 8px;
        font-size: 12px;
    }

    .stats-bar {
        gap: 6px;
        padding: 8px 10px;
        flex-wrap: wrap;
    }

    .stat-item {
        font-size: 11px;
        gap: 4px;
    }

    .stat-value {
        font-size: 12px;
    }

    .token-list {
        max-height: 160px;
        padding: 8px;
    }

    .token-item {
        padding: 6px 8px;
        font-size: 11px;
    }

    .token-empty {
        padding: 12px;
        font-size: 11px;
    }

    .toast-container {
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 12px;
        max-width: none;
    }

    .toast {
        font-size: 12px;
        padding: 10px 12px;
    }

    .user-info-mini {
        padding: 8px 10px;
        font-size: 11px;
    }

    .log-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    .log-filter {
        flex-wrap: wrap;
    }

    #logOutput {
        font-size: 10px;
        padding: 6px 8px;
    }
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}
