* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #10131a;
    color: #e6e8ee;
    overflow: hidden;
    overscroll-behavior: none;
}
/* iOS Safari'de overflow:hidden tek basina "lastik" (rubber-band) kaydirmayi/zipla-
   mayi engellemiyor - sayfa sag/sol veya yukari/asagi kayabiliyor. position:fixed
   govdeyi tamamen viewport'a sabitleyip bunu tamamen engelliyor. */
body {
    position: fixed;
    inset: 0;
    width: 100%;
}

[hidden] { display: none !important; }

/* ---------- Auth screens ---------- */
#auth-screen {
    height: 100vh;
    height: 100dvh; /* mobil tarayicilarda adres cubugu daralinca gercek gorunur yukseklik */
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: min(320px, calc(100vw - 32px));
    background: #1a1e29;
    border: 1px solid #2a2f3d;
    border-radius: 10px;
    padding: 28px;
}

.auth-card h1 {
    font-size: 18px;
    margin: 0 0 4px;
}

.auth-card p.hint {
    font-size: 13px;
    color: #8b93a7;
    margin: 0 0 20px;
}

.auth-card input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: #10131a;
    border: 1px solid #2a2f3d;
    border-radius: 6px;
    color: #e6e8ee;
    font-size: 14px;
}

.auth-card button {
    width: 100%;
    padding: 10px 12px;
    background: #3b82f6;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.auth-card button:hover { background: #2563eb; }
.auth-card button:disabled { background: #33384a; cursor: default; }

.auth-error {
    color: #f87171;
    font-size: 13px;
    margin-bottom: 12px;
    min-height: 16px;
}

/* ---------- Desktop ---------- */
#desktop-screen {
    height: 100vh;
    height: 100dvh; /* mobil tarayicilarda adres cubugu daralinca gercek gorunur yukseklik */
    position: relative;
}

#desktop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(44px + env(safe-area-inset-bottom, 0px));
    background: radial-gradient(circle at 20% 20%, #1a2035, #10131a 70%);
    overflow: hidden;
}

#taskbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(44px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #161a24;
    border-top: 1px solid #2a2f3d;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 10px;
    padding-right: 10px;
}

#taskbar-items {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
}

.taskbar-chip {
    background: #232838;
    border: 1px solid #2f3548;
    color: #e6e8ee;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}
.taskbar-chip.active { border-color: #3b82f6; }

#clock {
    font-size: 12px;
    color: #8b93a7;
    white-space: nowrap;
    padding: 0 10px;
    flex-shrink: 0;
}

#logout-btn {
    background: transparent;
    border: 1px solid #2a2f3d;
    color: #8b93a7;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
#logout-btn:hover { color: #f87171; border-color: #f87171; }
#logout-btn:hover { color: #e6e8ee; border-color: #3b82f6; }

#new-terminal-btn {
    background: transparent;
    border: 1px solid #2a2f3d;
    color: #8b93a7;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
#new-terminal-btn:hover { color: #e6e8ee; border-color: #3b82f6; }

/* ---------- Windows ---------- */
.window:focus { outline: none; }

.window {
    position: absolute;
    min-width: 320px;
    min-height: 200px;
    background: #14171f;
    border: 1px solid #2a2f3d;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.window-titlebar {
    height: 34px;
    background: #1c2029;
    display: flex;
    align-items: center;
    padding: 0 8px 0 12px;
    cursor: move;
    user-select: none;
    border-bottom: 1px solid #2a2f3d;
}

.window-title {
    flex: 1;
    font-size: 12px;
    color: #c3c9db;
}

.window-title-input {
    flex: 1;
    font-size: 12px;
    color: #e6e8ee;
    background: #10131a;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    padding: 2px 6px;
    margin-right: 6px;
    min-width: 0;
}

.window-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #8b93a7;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    margin-left: 2px;
}
.window-btn:hover { background: #2a2f3d; color: #e6e8ee; }
.window-btn.close:hover { background: #e11d48; color: white; }

.window-body {
    flex: 1;
    padding: 6px;
    overflow: hidden;
}

.window-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
}

.xterm { height: 100%; }

/* ---------- Desktop icons ---------- */
#desktop-icons {
    position: absolute;
    top: 16px;
    left: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 12px;
}

.desktop-icon {
    width: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 8px;
    cursor: grab;
    user-select: none;
}
.desktop-icon:active { cursor: grabbing; }
.desktop-icon:hover { background: rgba(255,255,255,0.06); }
.desktop-icon .icon-glyph { font-size: 30px; }
.desktop-icon .icon-label {
    font-size: 11px;
    color: #c3c9db;
    text-align: center;
    line-height: 1.2;
}

/* ---------- Notes ---------- */
.notes-wrap {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.notes-textarea {
    flex: 1;
    width: 100%;
    resize: none;
    background: #10131a;
    border: 1px solid #2a2f3d;
    border-radius: 6px;
    color: #e6e8ee;
    font-size: 13px;
    font-family: inherit;
    padding: 10px;
}
.notes-status {
    font-size: 11px;
    color: #8b93a7;
    padding: 4px 2px 0;
    min-height: 14px;
}

/* ---------- Notes folder browser ---------- */
.folder-toolbar {
    display: flex;
    gap: 8px;
    padding: 4px 4px 10px;
}
.folder-btn {
    background: #232838;
    border: 1px solid #2f3548;
    color: #e6e8ee;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}
.folder-btn:hover { border-color: #3b82f6; }

.folder-list {
    overflow-y: auto;
    height: calc(100% - 44px);
    padding: 0 2px;
}

.folder-section { margin-bottom: 10px; }

.folder-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 2px;
}
.folder-name {
    flex: 1;
    font-size: 12px;
    color: #c3c9db;
    font-weight: 600;
}

.icon-btn {
    background: transparent;
    border: none;
    color: #8b93a7;
    cursor: pointer;
    font-size: 12px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
}
.icon-btn:hover { background: #2a2f3d; color: #e6e8ee; }

.folder-notes {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 4px;
}
.folder-notes-root { margin-top: 4px; }

.note-row {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.note-row:hover { background: rgba(255,255,255,0.05); }
.note-row-title { flex: 1; }

.folder-empty {
    color: #8b93a7;
    font-size: 12px;
    padding: 20px 8px;
    text-align: center;
}

/* ---------- Calculator ---------- */
.calc-wrap {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.calc-display {
    width: 100%;
    padding: 12px 10px;
    font-size: 22px;
    text-align: right;
    background: #10131a;
    border: 1px solid #2a2f3d;
    border-radius: 6px;
    color: #e6e8ee;
}
.calc-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.calc-grid button {
    background: #232838;
    border: 1px solid #2f3548;
    border-radius: 6px;
    color: #e6e8ee;
    font-size: 15px;
    cursor: pointer;
}
.calc-grid button:hover { background: #2a2f3d; }
.calc-grid .calc-op { background: #2b3550; color: #93c5fd; }
.calc-grid .calc-eq { background: #3b82f6; color: white; grid-column: span 2; }
.calc-grid .calc-zero { grid-column: span 2; }

/* ---------- Rates widget ---------- */
/* Masaustunde sarmalayici kutu gorunmez kalsin (display:contents), cocuklar
   #desktop'a gore eskisi gibi absolute konumlansin - mobil breakpoint'te bu
   sarmalayiciyi gercek bir flex kutuya cevirip ikisini alt seride yan yana koyacagiz. */
#mobile-widgets { display: contents; }

#rates-widget {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 210px;
    background: #1a1e29;
    border: 1px solid #2a2f3d;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
}
#finance-widget {
    position: absolute;
    top: 158px;
    right: 16px;
    width: 210px;
    background: #1a1e29;
    border: 1px solid #2a2f3d;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
}
.rates-title { color: #c3c9db; font-weight: 600; margin-bottom: 6px; }
.rate-row {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    color: #8b93a7;
    padding: 2px 0;
}
.rate-code { color: #e6e8ee; font-weight: 600; }
.rates-updated {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #2a2f3d;
    font-size: 10px;
    color: #5c6478;
    text-align: right;
}

/* ---------- Sticky notes ---------- */
.sticky-note {
    position: absolute;
    min-width: 140px;
    min-height: 120px;
    border-radius: 4px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sticky-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    cursor: move;
    font-size: 11px;
    color: rgba(0,0,0,0.55);
}
.sticky-close {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: rgba(0,0,0,0.55);
    width: 20px;
    height: 20px;
    border-radius: 4px;
}
.sticky-close:hover { background: rgba(0,0,0,0.1); }
.sticky-body {
    flex: 1;
    resize: none;
    border: none;
    background: transparent;
    padding: 4px 8px 8px;
    font-size: 13px;
    color: #1f2430;
    font-family: inherit;
}
.sticky-body:focus { outline: none; }
.sticky-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
}

/* ---------- Context menu ---------- */
.context-menu {
    position: fixed;
    z-index: 9999;
    background: #1c2029;
    border: 1px solid #2f3548;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.5);
    padding: 4px;
    min-width: 170px;
}
.context-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: #e6e8ee;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}
.context-menu-item:hover { background: #2a2f3d; }

/* ---------- Site form ---------- */
.site-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    overflow-y: auto;
    padding: 2px 4px;
}
.site-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #8b93a7;
}
.site-form input {
    padding: 8px 10px;
    background: #10131a;
    border: 1px solid #2a2f3d;
    border-radius: 6px;
    color: #e6e8ee;
    font-size: 13px;
}
.site-form hr { border: none; border-top: 1px solid #2a2f3d; margin: 4px 0; }
.site-form-hint { font-size: 11px; color: #8b93a7; margin: 0; }
.site-form-actions { margin-top: auto; padding-top: 8px; }
.site-form-actions button {
    width: 100%;
    padding: 10px;
    background: #3b82f6;
    border: none;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    cursor: pointer;
}
.site-form-actions button:hover { background: #2563eb; }

/* ---------- Calendar ---------- */
.cal-wrap {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cal-nav-btn {
    background: #232838;
    border: 1px solid #2f3548;
    color: #e6e8ee;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
}
.cal-nav-btn:hover { background: #2a2f3d; }
.cal-month-label { font-size: 13px; font-weight: 600; color: #c3c9db; text-transform: capitalize; }

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 10px;
    color: #5c6478;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 6px;
    font-size: 12px;
    color: #c3c9db;
    cursor: pointer;
}
.cal-day:hover { background: rgba(255,255,255,0.06); }
.cal-day.today { border: 1px solid #3b82f6; }
.cal-day.selected { background: #3b82f6; color: white; }
.cal-day-dot {
    position: absolute;
    bottom: 4px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #f59e0b;
}
.cal-day.selected .cal-day-dot { background: white; }

.cal-day-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-top: 1px solid #2a2f3d;
    padding-top: 8px;
}
.cal-day-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.cal-day-panel-header span {
    font-size: 12px;
    color: #c3c9db;
    text-transform: capitalize;
}

.cal-reminder-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.reminder-row {
    background: #1c2029;
    border: 1px solid #2a2f3d;
    border-radius: 6px;
    padding: 6px 8px;
}
.reminder-row-main {
    display: flex;
    align-items: center;
    gap: 8px;
}
.reminder-time { font-size: 11px; color: #8b93a7; }
.reminder-title { flex: 1; font-size: 13px; color: #e6e8ee; }
.reminder-note { font-size: 11px; color: #8b93a7; margin-top: 4px; }

/* ---------- Mobil ---------- */
/* Pencereleri parmakla surukleyip yeniden boyutlandirmak telefonda kullanilamaz -
   bu genislikte pencereler dogrudan tam ekran acilir, surukleme/boyutlandirma
   JS'i devrede kalir ama gorsel olarak devre disi kalir (asagidaki !important). */
@media (max-width: 820px) {
    .window {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: auto !important;
        height: auto !important;
        border-radius: 0;
    }
    .window-resize-handle { display: none; }

    /* Tek dikey sutun yerine sarilan grid - cok sayida ikon ekran altina taşmasin. */
    #desktop-icons {
        top: 12px;
        left: 12px;
        right: 12px;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .desktop-icon { width: 74px; }

    /* Kaydirma tamamen kapali oldugu icin dövi/finans kutulari sag kenarda
       "kayarak" ulasilan bir yerde degil, taskbar'in hemen ustunde, her zaman
       gorunur yan yana bir seritte dursun. */
    #mobile-widgets {
        display: flex;
        position: absolute;
        left: 8px;
        right: 8px;
        bottom: 8px;
        gap: 8px;
        z-index: 1;
    }
    #rates-widget, #finance-widget {
        position: static;
        top: auto;
        right: auto;
        width: auto;
        flex: 1 1 0;
        min-width: 0;
        padding: 6px 8px;
        font-size: 10px;
    }
    #mobile-widgets .rates-title { font-size: 11px; margin-bottom: 3px; }
    #mobile-widgets .rate-row { font-size: 10px; padding: 1px 0; }
    #mobile-widgets .rates-updated { display: none; }

    /* Dar ekranda taskbar zaten sikisik - saat/tarih burada yer kaplamasin. */
    #clock { display: none; }
}

/* ---------- Tablolar (Excel tarzı, kişisel) ---------- */
.sheet-wrap {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sheet-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 6px;
    flex-shrink: 0;
}

.sheet-cellref {
    flex-shrink: 0;
    width: 46px;
    font-size: 12px;
    color: #8b93a7;
    background: #1c2029;
    border: 1px solid #2a2f3d;
    border-radius: 4px;
    padding: 5px 6px;
    text-align: center;
}

.sheet-formula-bar {
    flex: 1;
    min-width: 0;
    background: #10131a;
    border: 1px solid #2a2f3d;
    border-radius: 4px;
    color: #e6e8ee;
    font-size: 13px;
    font-family: inherit;
    padding: 6px 8px;
}
.sheet-formula-bar:focus { outline: none; border-color: #3b82f6; }

.sheet-status {
    flex-shrink: 0;
    font-size: 11px;
    color: #8b93a7;
    white-space: nowrap;
}

.sheet-grid-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border: 1px solid #2a2f3d;
    border-radius: 6px;
}

.sheet-loading {
    padding: 20px;
    text-align: center;
    color: #8b93a7;
    font-size: 12px;
}

table.sheet-table {
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
}

table.sheet-table th, table.sheet-table td {
    border: 1px solid #232838;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

table.sheet-table thead th {
    position: sticky;
    top: 0;
    background: #1c2029;
    color: #8b93a7;
    font-weight: 500;
    z-index: 2;
    user-select: none;
}

table.sheet-table tbody th {
    position: sticky;
    left: 0;
    background: #1c2029;
    color: #8b93a7;
    font-weight: 500;
    text-align: center;
    z-index: 1;
}

table.sheet-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
}

table.sheet-table tbody td {
    background: #14171f;
    color: #e6e8ee;
    cursor: cell;
}
table.sheet-table tbody td.selected {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
    background: #1a2540;
}

table.sheet-table thead th { position: relative; }
.sheet-col-resize {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
}
