*{box-sizing:border-box}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Hiragino Sans,Yu Gothic UI,sans-serif;background:linear-gradient(180deg,#e8f4fb,#f5f6f8 200px);color:#1a1a1a;line-height:1.7;min-height:100vh}body,h1{margin:0}h1{font-size:2rem;letter-spacing:.02em}.brand{display:flex;align-items:center;gap:1rem;margin-bottom:.25rem}.brand-icon{width:64px;height:64px;border-radius:14px;box-shadow:0 4px 16px rgba(14,165,233,.15)}.history-btn{margin-left:auto;padding:.45rem .8rem;background:linear-gradient(135deg,#fbbf24,#f59e0b);color:white;border:none;border-radius:8px;font-size:.85rem;font-weight:600;cursor:pointer;font-family:inherit;box-shadow:0 2px 6px rgba(245,158,11,.25)}.history-btn:hover{transform:translateY(-1px)}.history-overlay{position:fixed;inset:0;background:rgba(15,23,42,.6);z-index:1000;display:flex;align-items:flex-start;justify-content:center;padding:1rem;overflow-y:auto}.history-panel{background:white;border-radius:16px;width:100%;max-width:680px;max-height:85vh;overflow-y:auto;padding:1rem 1.25rem 1.5rem;margin-top:2rem;box-shadow:0 10px 40px rgba(0,0,0,.2)}.history-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem;padding-bottom:.5rem;border-bottom:1px solid #e2e8f0}.history-header h2{margin:0;font-size:1.1rem;color:#0c4a6e}.history-empty{padding:2rem 1rem;text-align:center;color:#94a3b8}.history-list{display:flex;flex-direction:column;gap:.5rem}.history-item{display:flex;align-items:center;gap:.75rem;padding:.6rem;background:#f8fafc;border:1px solid #e2e8f0;border-radius:10px;cursor:pointer;transition:all .15s;position:relative}.history-item:hover{background:#f0f9ff;border-color:#7dd3fc}.history-thumb{width:60px;height:60px;object-fit:cover;border-radius:6px;background:#f1f5f9;flex-shrink:0}.history-info{flex:1 1;min-width:0}.history-date{font-size:.75rem;color:#64748b}.history-mode{font-size:.75rem;color:#0369a1;font-weight:600;margin:.15rem 0}.history-title{font-size:.85rem;color:#1e293b;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.history-delete{width:26px;height:26px;border-radius:50%;border:none;background:#ef4444;color:white;cursor:pointer;font-weight:700;flex-shrink:0}.history-delete:hover{background:#dc2626}.tagline{color:#0ea5e9;font-size:1rem;font-weight:600;margin:0 0 1rem;letter-spacing:.05em}.container{max-width:720px;margin:0 auto;padding:2rem 1.25rem}.lead{color:#666;margin:0 0 2rem}.upload-card{display:block;background:white;border:2px dashed #cbd5e0;border-radius:12px;padding:2rem;text-align:center;cursor:pointer;transition:border-color .2s}.upload-card:hover{border-color:#0ea5e9}.upload-card.has-image{border-style:solid;padding:1rem}.upload-card input[type=file]{display:none}.preview{max-width:100%;max-height:400px;border-radius:8px}.upload-hint{color:#888;font-size:.9rem}.btn{display:inline-block;padding:.75rem 1.5rem;background:linear-gradient(135deg,#0ea5e9,#38bdf8);color:white;border:none;border-radius:8px;font-size:1rem;font-weight:600;cursor:pointer;margin-top:1rem;box-shadow:0 2px 8px rgba(14,165,233,.25)}.btn:disabled{background:#ccc;cursor:not-allowed}.btn.done{cursor:default;opacity:1}.btn.done,.btn.done:disabled{background:linear-gradient(135deg,#10b981,#059669)}.btn.done:disabled{color:white}.btn-tokeru-icon{width:1.4em;height:1.4em;margin-right:.5em;vertical-align:middle;border-radius:6px;background:rgba(255,255,255,.95);padding:1px}.btn-tokeru-icon.thinking{animation:tokeru-pulse 1.2s ease-in-out infinite}@keyframes tokeru-pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.15);opacity:.75}}.btn.secondary{background:white;color:#555;border:1px solid #ddd;margin-left:.5rem}.result{margin-top:2rem;background:white;border-radius:12px;padding:1.5rem;box-shadow:0 2px 8px rgba(0,0,0,.06)}.result-body{line-height:1.8}.result-body p{margin:.5em 0}.result-body strong{color:#0284c7;font-weight:700}.result-body ol,.result-body ul{padding-left:1.5em;margin:.5em 0}.result-body li{margin:.25em 0}.result-body code{background:#f1f5f9;padding:.1em .4em;border-radius:4px;font-family:Consolas,monospace;font-size:.95em}.result-body h2,.result-body h3{color:#0ea5e9;margin:1em 0 .5em;font-size:1.05em}.result-body svg:not(.katex svg):not(.katex *){max-width:100%;height:auto;display:block;margin:1em auto;background:white;border:1px solid #e2e8f0;border-radius:8px}.result-body svg image{image-rendering:-webkit-optimize-contrast;image-rendering:crisp-edges}.mermaid-diagram{display:flex;justify-content:center;margin:1em 0;padding:.75em;background:#f8fafc;border-radius:8px;overflow-x:auto}.mermaid-diagram svg{max-width:100%;height:auto;background:transparent;border:none}.mermaid-error{margin:1em 0;padding:.75em;background:#fef2f2;border:1px solid #fca5a5;border-radius:8px;color:#991b1b;font-size:.85em}.mermaid-error pre{background:white;padding:.5em;border-radius:4px;margin-top:.5em;font-size:.8em;overflow-x:auto}.tr-pair{margin:.8em 0 1.2em;padding:.6em .8em;background:#f8fafc;border-left:3px solid #0ea5e9;border-radius:6px}.tr-en,.tr-ja{margin:.2em 0;line-height:1.9}.tr-en{font-size:1.02em}.tr-ja{color:#334155;font-size:.95em;padding-left:1em}.tr-ja:before{content:"→ ";color:#94a3b8}.tr-s{background:#d1fae5;color:#065f46}.tr-s,.tr-v{padding:.05em .35em;border-radius:4px;font-weight:600}.tr-v{background:#fee2e2;color:#991b1b}.tr-o{background:#dbeafe;color:#1e3a8a}.tr-c,.tr-o{padding:.05em .35em;border-radius:4px;font-weight:600}.tr-c{background:#f3e8ff;color:#6b21a8}.tr-m{background:#f1f5f9;color:#475569;padding:.05em .35em;border-radius:4px}.tr-legend{display:flex;flex-wrap:wrap;gap:.4em;margin:.5em 0 1em;font-size:.8em;color:#475569}.tr-legend span{display:inline-block}.result h2{margin-top:0;font-size:1.1rem;color:#0ea5e9}.error{margin-top:2rem;background:#fee;border:1px solid #fcc;border-radius:8px;padding:1rem;color:#c33;white-space:pre-wrap;word-break:break-word}.spinner{display:inline-block;width:1rem;height:1rem;border:2px solid #fff;border-top-color:transparent;border-radius:50%;animation:spin .8s linear infinite;margin-right:.5rem;vertical-align:middle}@keyframes spin{to{transform:rotate(1turn)}}.subject-select{margin:1rem 0}.subject-select label{display:inline-flex;align-items:center;margin-right:1rem;cursor:pointer}.subject-select input{margin-right:.35rem}.subject-pill{margin:0 .3rem .3rem 0;padding:.35rem .7rem;background:white;border:1.5px solid #cbd5e0;border-radius:999px;font-family:inherit;font-size:.85rem;color:#475569;cursor:pointer;transition:all .15s}.subject-pill:hover{border-color:#0ea5e9;color:#0c4a6e}.subject-pill.active{background:linear-gradient(135deg,#0ea5e9,#38bdf8);border-color:#0284c7;color:white;font-weight:700;box-shadow:0 2px 6px rgba(14,165,233,.3)}.mode-section{margin:1.5rem 0 1rem}.mode-label{font-weight:700;font-size:1.05rem;color:#0c4a6e;margin-bottom:.75rem;text-align:center}.mode-grid{display:grid;grid-template-columns:repeat(3,1fr);grid-gap:.75rem;gap:.75rem}.mode-grid.four{grid-template-columns:repeat(4,1fr)}.mode-grid.five{grid-template-columns:repeat(5,1fr)}@media (max-width:640px){.mode-grid.five,.mode-grid.four{grid-template-columns:repeat(2,1fr)}}.mode-card{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:1.25rem .5rem;background:white;border:2px solid #e0e7ef;border-radius:14px;cursor:pointer;transition:all .2s;font-family:inherit;color:inherit}.mode-card:hover{border-color:#38bdf8;transform:translateY(-2px);box-shadow:0 4px 12px rgba(14,165,233,.12)}.mode-card:active{transform:translateY(0)}.mode-card.active{border-color:#0ea5e9;background:linear-gradient(135deg,#f0f9ff,#e0f2fe);box-shadow:0 4px 16px rgba(14,165,233,.25);transform:translateY(-2px)}.mode-card-icon{font-size:2rem;margin-bottom:.4rem;line-height:1}.mode-card-name{font-weight:700;font-size:1.05rem;color:#0c4a6e;margin-bottom:.15rem;line-height:1.2;word-break:keep-all;text-align:center}.mode-card.active .mode-card-name{color:#0369a1}.mode-card-desc{font-size:.75rem;color:#64748b;line-height:1.3;text-align:center;word-break:keep-all}@media (max-width:600px){.mode-grid{gap:.5rem}.mode-card{padding:.9rem .2rem}.mode-card-icon{font-size:1.6rem;margin-bottom:.3rem}.mode-card-name{font-size:.85rem}.mode-card-desc{font-size:.65rem;line-height:1.25}}@media (max-width:380px){.mode-card-name{font-size:.78rem}.mode-card-desc{font-size:.6rem}}.confirm-toggle{display:inline-flex;align-items:center;margin:1rem 0 .5rem;padding:.5rem .75rem;background:#e0f2fe;border:1px solid #7dd3fc;border-radius:8px;cursor:pointer;font-size:.9rem;color:#0c4a6e}.confirm-toggle input{margin-right:.5rem;cursor:pointer}.figure-toggle{display:inline-flex;align-items:center;margin:.25rem 0;padding:.5rem .75rem;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;cursor:pointer;font-size:.85rem;color:#78350f}.figure-toggle input{margin-right:.5rem;cursor:pointer}.ocr-confirm{margin-top:1.5rem;padding:1.25rem;background:#f0f9ff;border:2px solid #0ea5e9;border-radius:12px}.ocr-confirm-title{font-size:1.1rem;font-weight:700;color:#0c4a6e;margin-bottom:.75rem}.ocr-confirm-body{background:white;padding:1rem;border-radius:8px;margin-bottom:1rem;line-height:1.7}.ocr-confirm-question{font-weight:600;color:#0369a1;margin:.75rem 0;text-align:center}.ocr-confirm-buttons{display:flex;gap:.5rem;flex-wrap:wrap}.ocr-edit-input{width:100%;padding:.75rem;border:1.5px solid #7dd3fc;border-radius:8px;font-family:inherit;font-size:.95rem;line-height:1.6;background:white;color:#1e293b;resize:vertical;min-height:200px;margin-bottom:.75rem}.ocr-edit-input:focus{outline:none;border-color:#0ea5e9;box-shadow:0 0 0 3px rgba(14,165,233,.15)}.turn-num{font-size:.75rem;color:#94a3b8;font-weight:500;margin-left:.5em}.user-bubble{margin-top:1.5rem;background:#e0f2fe;border-left:4px solid #0ea5e9;border-radius:8px;padding:.85rem 1rem}.user-bubble-label{font-size:.85rem;color:#0369a1;font-weight:600;margin-bottom:.35rem}.user-bubble-text{color:#1e293b;white-space:pre-wrap}.followup-box{margin-top:1.5rem;padding:1rem;background:#fef9e7;border:1px dashed #fde68a;border-radius:12px}.followup-label{font-weight:600;color:#78350f}.followup-input,.followup-label{font-size:.95rem;margin-bottom:.5rem}.followup-input{width:100%;padding:.6rem .75rem;border:1.5px solid #fde68a;border-radius:8px;font-family:inherit;resize:vertical;min-height:60px;background:white;color:#1e293b;line-height:1.5}.followup-input:focus{outline:none;border-color:#f59e0b;box-shadow:0 0 0 3px rgba(245,158,11,.15)}.crop-actions{display:flex;flex-wrap:wrap;gap:.5rem;margin:.75rem 0}.btn-tiny{padding:.55rem .9rem;background:linear-gradient(135deg,#fbbf24,#f59e0b);color:white;border:none;border-radius:8px;font-size:.9rem;font-weight:600;cursor:pointer;font-family:inherit;box-shadow:0 2px 6px rgba(245,158,11,.25)}.btn-tiny.secondary{background:white;color:#475569;border:1.5px solid #cbd5e0;box-shadow:none}.btn-tiny:hover{transform:translateY(-1px)}.btn-tiny:active{transform:translateY(0)}.cropper-section{margin:1rem 0 1.25rem;padding:1rem;background:#f8fafc;border:2px solid #0ea5e9;border-radius:12px}.cropper-hint{font-size:.85rem;color:#0369a1;margin-bottom:.6rem;text-align:center;font-weight:500}.cropper-container{position:relative;width:100%;height:400px;background:#1e293b;border-radius:8px;overflow:hidden}.crop-buttons{display:flex;gap:.5rem;margin-top:.75rem;flex-wrap:wrap}.pdf-preview{display:flex;flex-direction:column;align-items:center;padding:1.5rem 1rem}.pdf-icon{font-size:4rem;line-height:1;margin-bottom:.5rem}.pdf-name{font-weight:600;font-size:1rem;color:#1e293b;text-align:center;word-break:break-all;margin-bottom:.25rem}.pdf-size{font-size:.85rem;color:#64748b;margin-bottom:.5rem}.pdf-note{font-size:.75rem;color:#0369a1;background:#e0f2fe;padding:.25rem .6rem;border-radius:4px}.pdf-loading{display:flex;flex-direction:column;align-items:center;gap:.75rem;padding:1rem;color:#475569}.spinner-large{display:inline-block;width:2rem;height:2rem;border:3px solid #0ea5e9;border-top-color:transparent;border-radius:50%;animation:spin .8s linear infinite}.pdf-nav{display:flex;align-items:center;justify-content:space-between;gap:.5rem;margin:.75rem 0;padding:.65rem .75rem;background:#fef9e7;border:1px solid #fde68a;border-radius:10px;flex-wrap:wrap}.pdf-nav-info{font-size:.85rem;color:#78350f;text-align:center;flex:1 1;min-width:0}.pdf-nav-info strong{font-size:.95rem}.pieces-section{margin:1rem 0;padding:.85rem 1rem;background:#ecfdf5;border:2px solid #34d399;border-radius:12px}.pieces-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.6rem;font-weight:600;font-size:.95rem;color:#064e3b}.pieces-list{display:flex;flex-wrap:wrap;gap:.5rem;margin-bottom:.5rem}.piece-item{position:relative;display:flex;flex-direction:column;align-items:center;background:white;border:1.5px solid #6ee7b7;border-radius:8px;padding:.35rem;width:110px}.piece-thumb{width:100%;height:80px;object-fit:cover;border-radius:4px;background:#f1f5f9}.piece-label{font-size:.7rem;color:#047857;margin-top:.3rem;text-align:center;font-weight:500}.piece-remove{position:absolute;top:-8px;right:-8px;width:22px;height:22px;border-radius:50%;border:2px solid white;background:#ef4444;color:white;font-weight:700;font-size:1rem;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1}.piece-remove:hover{background:#dc2626}.pieces-hint{font-size:.8rem;color:#065f46;background:white;padding:.4rem .6rem;border-radius:6px;margin-top:.3rem}.figure-tools{display:flex;align-items:center;gap:.75rem;margin:1rem 0 .5rem}.figure-count{font-size:.85rem;color:#475569;font-weight:600}.figure-refs{margin:1rem 0 1.5rem;padding:1rem;background:#fef3c7;border:2px solid #f59e0b;border-radius:12px}.figure-refs-header{font-weight:700;font-size:1rem;color:#92400e;margin-bottom:.75rem}.figure-refs-list{display:flex;flex-wrap:wrap;gap:.75rem}.figure-ref-item{position:relative;background:white;border:1.5px solid #fbbf24;border-radius:8px;padding:.5rem;flex:1 1 200px;max-width:320px}.figure-ref-img{width:100%;height:auto;border-radius:4px;display:block}.figure-ref-label{text-align:center;font-size:.85rem;color:#92400e;font-weight:600;margin-top:.35rem}@media (max-width:480px){.cropper-container{height:320px}}.katex .katex-mathml,.katex-mathml,math{display:none!important;visibility:hidden!important;position:absolute!important;clip:rect(0,0,0,0)!important;width:1px!important;height:1px!important;overflow:hidden!important;pointer-events:none!important}