:root {
    /* Primary Brand Colors */
    --brand-primary: #010080;        /* Dark blue - main brand */
    --brand-secondary: #e0d3b3;   /* Gold/yellow - accent */
    --brand-white: #fff;                        /* Pure white */
    
    /* UI Colors */
    --color-background: #f9f9f9;               /* Main background */
    --color-background-gradient: linear-gradient(135deg, #e3f0ff 0%, #f9f9f9 100%);
    --color-surface-secondary: #f8f9fa;       /* Secondary surfaces */
    --color-surface-alt: #f5f7fa;             /* Alternative surface */
    
    /* Text Colors */
    --color-text-primary: #333;               /* Main text */
    --color-text-secondary: #666;             /* Secondary text */
    --color-text-muted: #999;                 /* Muted/placeholder text */
    --color-text-brand: var(--brand-primary); /* Brand colored text */
    
    /* Border Colors */
    --color-border: #ddd;                     /* Default borders */
    --color-border-light: #eee;              /* Light borders */
    --color-border-lighter: #f0f0f0;         /* Lighter borders */
    --color-border-medium: #e0e0e0;          /* Medium borders */
    --color-border-separator: #e8e8e8;       /* Section separators */
    
    /* State Colors */
    --color-error: #fe0100;                  /* Error states */
    --color-warning: #ff9b7c;                /* Warning states */
    --color-info: #007bff;                   /* Info states */
    --color-neutral: #6c757d;                /* Neutral actions */
    
    /* Interactive Colors */
    --color-hover-yellow: #ffe066;           /* Yellow hover states */
    --color-hover-brand: rgba(5, 35, 97, 0.05); /* Brand hover background */
    --color-focus: rgba(5, 35, 97, 0.1);     /* Focus states */
    --color-disabled: rgba(5, 35, 97, 0.5);  /* Disabled states */
    
    /* Shadow Colors */
    --shadow-light: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-medium: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-strong: 0 2px 12px rgba(0,0,0,0.1);
    --shadow-popup: 0 4px 16px rgba(0,0,0,0.2);
    --shadow-overlay: rgba(0,0,0,0.5);

    /* Dictation */
    --color-mic-live: #2e9e5b;
    --color-mic-cloud: #d98324;
    --z-dictation: 60;
}
body {
    background: var(--color-background-gradient);
    font-family: 'Noto Sans Devanagari', 'Roboto', Arial, sans-serif;
    min-height: 100vh;
    margin: 0;
}

#container {
    max-width: 1000px;
    margin: 20px auto;
    background: var(--brand-white);
    border-radius: 12px;
    box-shadow: var(--shadow-strong);
    padding: 32px;
}

.header-gov {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--color-border-separator);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logo img {
    height: 80px;
}

.logo-text h1 {
    font-family: 'Noto Sans Devanagari', sans-serif;
    font-size: 2.5em;
    margin: 0;
    color: var(--color-text-brand);
}

.logo-text p {
    margin: 0;
    color: var(--color-text-primary);
}


.editor-wrapper {
    position: relative;
    background: var(--brand-white);
    border-radius: 8px;
    box-shadow: var(--shadow-medium);
    width: 70%;
    margin-top: 10px;
    box-sizing: border-box;
    overflow: visible;
}

.editor-wrapper.editor-letter {
    background: transparent;
    width: 210mm;
    min-height: 0;
    margin: 70px auto 48px auto;
    box-sizing: border-box;
    padding: 0;
    overflow: visible;
    display: block;
    position: relative;
    box-shadow: none;
}

.letter-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    width: 100%;
}

.letter-page {
    position: relative;
    width: 210mm;
    height: 297mm;
    box-sizing: border-box;
    padding: 25.4mm;
    background: var(--brand-white);
    box-shadow: var(--shadow-strong);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.letter-page-chrome {
    position: absolute;
    top: 6px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 3;
}

.letter-page-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    background: var(--color-surface-secondary);
    padding: 2px 8px;
    border-radius: 999px;
}

.letter-page-input {
    display: block;
    width: 100%;
    flex: 1 1 auto;
    height: 912px;
    max-height: 912px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 0;
    font-size: 16px;
    line-height: 24px;
    resize: none;
    font-family: 'Noto Sans Devanagari', sans-serif;
    box-sizing: border-box;
    overflow: hidden;
    background: transparent;
    color: var(--color-text-primary);
    outline: none;
}

.letter-page-input:focus {
    outline: none;
}

/* Legacy dashed markers removed — letter now uses diary-style page cards */

.page-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 6px 12px;
    background: var(--brand-primary);
    color: var(--brand-white);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow-medium);
    z-index: 20;
    pointer-events: none;
    width: fit-content;
}

.page-indicator[hidden] {
    display: none !important;
}

.editor-wrapper.editor-diary {
    background: transparent;
    width: 210mm;
    min-height: 0;
    margin: 70px auto 48px auto;
    box-sizing: border-box;
    padding: 0;
    font-family: 'Noto Sans Devanagari', Arial, sans-serif;
    font-size: 15px;
    line-height: 24px;
    color: var(--color-text-primary);
    box-shadow: none;
    overflow: visible;
}

.diary-pages {
    --diary-left-col: 25%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    width: 100%;
}

.diary-page {
    position: relative;
    width: 210mm;
    height: 297mm;
    box-sizing: border-box;
    padding: 12.7mm;
    background: var(--brand-white);
    box-shadow: var(--shadow-strong);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.diary-page-chrome {
    position: absolute;
    top: 6px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 3;
}

.diary-page-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    background: var(--color-background);
    padding: 2px 8px;
    border-radius: 999px;
}

.diary-header-toggle {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--color-border-light);
    background: var(--brand-secondary);
    color: var(--brand-primary);
    cursor: pointer;
}

.diary-header-toggle[aria-pressed="true"] {
    background: var(--brand-primary);
    color: var(--brand-white);
    border-color: var(--brand-primary);
}

.diary-page-delete {
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
}

.diary-page-delete:hover {
    color: var(--color-error);
}

.diary-page-header {
    flex: 0 0 auto;
    margin-bottom: 4px;
    max-height: 148px;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.4;
}

.diary-header-top {
    display: grid;
    grid-template-columns: minmax(100px, 0.85fr) minmax(160px, 1.15fr) minmax(240px, 1.6fr);
    grid-template-rows: auto auto auto auto;
    column-gap: 10px;
    row-gap: 2px;
    align-items: baseline;
    margin-bottom: 4px;
}

/* Flatten so schedule/title/against lines share grid rows with each other */
.diary-header-text,
.diary-header-title,
.diary-header-against {
    display: contents;
}

.diary-header-text > span {
    grid-column: 1;
    font-size: 11px;
    line-height: 1.35;
}

.diary-header-text > span:nth-child(1) {
    grid-row: 1;
}

.diary-header-text > span:nth-child(2) {
    grid-row: 2;
}

.diary-title-line {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: nowrap;
    font-size: 16px;
    font-weight: 700;
    justify-self: center;
    transform: translateX(42px);
}

.diary-rule-line {
    grid-column: 2;
    grid-row: 3;
    display: flex;
    align-items: baseline;
    justify-content: center;
    font-size: 12px;
    font-weight: 400;
    justify-self: center;
    transform: translateX(42px);
}

.diary-header-against > .diary-against-line:nth-child(1) {
    grid-column: 3;
    grid-row: 3;
    justify-self: end;
}

.diary-header-against > .diary-against-line:nth-child(2) {
    grid-column: 3;
    grid-row: 4;
    justify-self: end;
}

.diary-against-line {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    flex-wrap: nowrap;
    width: 100%;
    gap: 0;
    font-size: 12px;
}

.diary-meta-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 2px 0;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.7;
}

.diary-label {
    white-space: nowrap;
    font-weight: 500;
}

.diary-dotted {
    display: inline-block;
    border: none;
    border-bottom: 1px dotted #000;
    border-radius: 0;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    font-weight: 400;
    color: inherit;
    text-align: center;
    padding: 0 0.35em;
    margin: 0 0.25em;
    min-width: 72px;
    max-width: 160px;
    height: 1.35em;
    line-height: 1.35;
    box-sizing: content-box;
    vertical-align: baseline;
}

.diary-dotted:focus {
    outline: none;
    border-bottom-color: var(--brand-primary);
}

.diary-dotted-narrow {
    min-width: 48px;
    max-width: 64px;
}

.diary-dotted-wide {
    flex: 1 1 0;
    min-width: 80px;
    max-width: none;
}

.diary-dotted-date {
    min-width: 110px;
    max-width: 130px;
    flex: 0 0 auto;
}

.diary-page-header input[data-field="thana"],
.diary-page-header input[data-field="district"] {
    flex: 1 1 0;
    min-width: 72px;
    max-width: none;
}

.diary-page-header input[data-field="fir_number"] {
    max-width: 88px;
    min-width: 56px;
    flex: 0 1 auto;
}

.diary-page-header input[data-field="against_1"],
.diary-page-header input[data-field="against_2"] {
    max-width: 88px;
    min-width: 52px;
    flex: 1 1 52px;
}

.diary-page-header input[data-field="special_report_no"] {
    flex: 0 1 auto;
    width: 9.5em;
    max-width: 9.5em;
    min-width: 4.5em;
}

.diary-header-divider {
    margin-top: 6px;
    border-top: 1.5px solid #000;
}

.fir-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
    box-shadow: none;
    table-layout: fixed;
    border: 1.5px solid #000;
    flex: 0 0 auto;
}

.fir-table th {
    background: transparent;
    padding: 6px 8px;
    text-align: center;
    font-weight: 700;
    border: 1px solid #000;
    font-size: 12px;
    line-height: 1.3;
    color: var(--color-text-primary);
    height: 72px;
    box-sizing: border-box;
}

.fir-table th.left-column,
.fir-table td.left-column {
    width: var(--diary-left-col, 25%);
}

.fir-table th.right-column,
.fir-table td.right-column {
    width: calc(100% - var(--diary-left-col, 25%));
}

.fir-table th.right-column input {
    display: block;
    margin: 4px auto 0;
    width: 48px;
    text-align: center;
    border: none;
    border-bottom: 1px dotted #333;
    background: transparent;
    font-size: 12px;
}

.fir-table td {
    padding: 0;
    border: 1px solid #000;
    vertical-align: top;
    background: var(--brand-white);
    word-wrap: break-word;
}

.diary-cell {
    position: relative;
    width: 100%;
    height: var(--diary-box-h, 768px);
    box-sizing: border-box;
    overflow: hidden;
}

.fir-input {
    display: block;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border: none;
    resize: none;
    overflow: hidden;
    font-family: 'Noto Sans Devanagari', Arial, sans-serif;
    font-size: 15px;
    line-height: 24px;
    padding: 4px 6px;
    margin: 0;
    background: transparent;
    color: var(--color-text-primary);
    outline: none;
}

.fir-input.diary-box-overflow {
    outline: none;
}

.diary-cell.diary-box-overflow {
    outline: 2px solid var(--color-error);
    outline-offset: -1px;
}

.diary-add-page {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px auto 24px;
    padding: 10px 18px;
    border: 1px dashed var(--brand-primary);
    border-radius: 8px;
    background: var(--brand-secondary);
    color: var(--brand-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.diary-add-page:hover {
    background: var(--color-hover-brand);
}

@media print {
    .screen-only {
        display: none !important;
    }
}



#exportBtn {
    background: var(--brand-primary);
    color: var(--brand-white);
    border: none;
    border-radius: 8px;
    padding: 0 14px;
    height: 36px;
    font-size: 0.95em;
    cursor: pointer;
    box-shadow: var(--shadow-light);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#exportBtn:hover {
    filter: brightness(1.08);
    color: var(--brand-white);
    box-shadow: var(--shadow-medium);
    transform: translateY(-1px);
}

#exportBtn i {
    color: var(--brand-white);
}

#exportBtn span:not(.btn-icon) {
    font-size: 14px;
    font-weight: 500;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
}

@keyframes header-icon-spin {
    to { transform: rotate(360deg); }
}

.is-busy .btn-icon i {
    animation: header-icon-spin 0.8s linear infinite;
}

.drive-control {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.doc-name-cluster {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1 1 200px;
    max-width: 320px;
}

#driveConnectBtn,
#driveAccountBtn {
    background: var(--brand-white);
    color: var(--brand-primary);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 0.9em;
    cursor: pointer;
    box-shadow: var(--shadow-light);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ID display rules override the UA [hidden] stylesheet — force hide */
#driveConnectBtn[hidden],
#driveAccountBtn[hidden] {
    display: none !important;
}

#driveConnectBtn:hover,
#driveAccountBtn:hover {
    background: var(--color-hover-brand);
    box-shadow: var(--shadow-medium);
}

#driveConnectBtn i,
#driveAccountBtn i {
    color: var(--brand-primary);
    font-size: 15px;
}

#driveAccountBtn[data-sync="error"] {
    border-color: var(--color-error);
}

#driveAccountBtn[data-sync="error"] i {
    color: var(--color-error);
}

#driveAccountBtn[data-sync="syncing"] {
    cursor: wait;
}

.drive-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: var(--brand-white);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-medium);
    z-index: 1100;
    padding: 4px;
    display: flex;
    flex-direction: column;
}

.drive-menu[hidden] {
    display: none !important;
}

.drive-menu-email {
    padding: 8px 12px 4px;
    font-size: 12px;
    color: var(--color-text-muted);
    word-break: break-all;
    border-bottom: 1px solid var(--color-border-lighter);
    margin-bottom: 2px;
}

.drive-menu-email[hidden] {
    display: none !important;
}

.drive-menu-item {
    appearance: none;
    border: none;
    background: transparent;
    text-align: left;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--brand-primary);
    cursor: pointer;
}

.drive-menu-item:hover {
    background: var(--color-hover-brand);
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--brand-primary);
}

.history-sync-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    font-size: 11px;
    vertical-align: middle;
}

.history-sync-badge.is-synced {
    color: #2e7d32;
}

.history-sync-badge.is-pending {
    color: #c47a00;
}

.history-sync-badge.is-error {
    color: var(--color-error);
}

.brand-mark-hindi {
    font-family: 'Noto Sans Devanagari', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--brand-primary);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.switch-btn {
    background: var(--brand-white);
    border: none;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
    height: 36px;
    width: 36px;
    flex-shrink: 0;
}

.switch-btn:hover,
.switch-btn.active {
    background: var(--color-hover-brand);
    box-shadow: var(--shadow-medium);
}

.switch-icon {
    font-size: 16px;
    color: var(--brand-primary);
    transition: transform 0.2s ease;
}

.segmented {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    background: var(--brand-white);
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    gap: 2px;
}

.segment-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-family: "Roboto", Helvetica, sans-serif;
    font-size: 13px;
    font-weight: 500;
    height: 30px;
    padding: 0 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.segment-btn:hover {
    color: var(--brand-primary);
}

.segment-btn.is-active {
    background: var(--brand-primary);
    color: var(--brand-white);
}

.add-template-btn {
    background: var(--brand-white);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-light);
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.add-template-btn:hover {
    background: var(--color-hover-brand);
    box-shadow: var(--shadow-medium);
    transform: scale(1.06);
}
.plus-icon i {
    color: var(--brand-primary);
    font-size: 16px;
}

.filename-input {
    height: 36px;
    width: 100%;
    min-width: 100px;
    flex: 1 1 auto;
    padding: 0 12px;
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    font-family: "Roboto", Helvetica, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
    background: var(--brand-white);
    box-shadow: var(--shadow-light);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.filename-input:hover {
    border-color: var(--color-border);
}

.filename-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-medium);
}

.header-frame {
    background-color: var(--brand-secondary);
    color: var(--brand-primary);
    width: 100%;
    height: 56px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-shadow: var(--shadow-light);
    border-top: 3px solid var(--color-error);
    border-bottom: 2px solid var(--brand-primary);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1728px;
    height: 100%;
    margin: 0 auto;
    padding: 0 14px;
    gap: 12px;
}

.header-left, .header-center, .header-right {
    display: flex;
    align-items: center;
}

.header-left {
    flex: 1 1 0;
    min-width: 0;
    gap: 8px;
}

.header-center {
    flex: 0 0 auto;
    justify-content: center;
}

.header-right {
    flex: 1 1 0;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

/* New File Modal Styles */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 16px;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    left: -300px;
    top: 45px;
    width: 300px;
    height: calc(100vh - 45px);
    background-color: var(--brand-white);
    box-shadow: var(--shadow-medium);
    transition: left 0.3s ease;
    z-index: 900;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Prevent horizontal scroll */
    background: var(--brand-white);
}

.sidebar.open {
    left: 0;
}

.sidebar-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.template-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
    box-sizing: border-box; /* Include padding in width */
}

.template-item:hover {
    background-color: var(--color-hover-brand);
}

.template-item i {
    color: var(--brand-primary);
    font-size: 16px;
    min-width: 16px; /* Fixed width for icon */
}

.template-item span {
    color: var(--brand-primary);
    font-family: "Roboto-Medium", Helvetica;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Footer Styles */
.sidebar-footer {
    position: relative;
    width: 100%;
    padding: 15px 20px;
    border-top: 1px solid var(--color-border-light);
    background: var(--brand-white);
    margin-top: auto;
    box-sizing: border-box; /* Include padding in width */
}

/* Preview Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--shadow-overlay);
    z-index: 1000;
}

.modal-content {
    position: relative;
    background: white;
    margin: 5% auto;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: var(--shadow-popup);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.close-btn {
    font-size: 24px;
    font-weight: bold;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0 8px;
}

.modal-body {
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border-light);
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.btn-secondary {
    background: var(--color-neutral);
    color: white;
}

.btn-primary {
    background: var(--color-info);
    color: white;
}

.preview-page {
    font-family: 'Noto Sans Devanagari', sans-serif;
    padding: 20px;
    background: white;
}

.restore-message {
    position: fixed;
    bottom: 64px;
    right: 24px;
    background: var(--color-info);
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: var(--shadow-popup);
    z-index: 1000;
    font-size: 0.9em;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.restore-message.fade-out {
    opacity: 0;
}

/* History List Styles */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    padding: 10px 0;
}

.history-date-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-header {
    font-family: "Roboto-Medium", Helvetica;
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--color-border-lighter);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.history-item:hover {
    background: var(--color-hover-brand);
}

.history-item.is-active {
    background: rgba(5, 35, 97, 0.08);
    box-shadow: inset 3px 0 0 var(--brand-primary);
}

.history-item-details {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.history-empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 14px;
    line-height: 1.5;
}

.history-empty strong {
    display: block;
    color: var(--color-text-primary);
    margin-bottom: 6px;
    font-weight: 600;
}

.history-empty span {
    display: block;
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.history-item-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    margin-right: 8px;
    transition: opacity 0.2s ease;
}

.history-item-actions button {
    border: none;
    background: none;
    border-radius: 4px;
    padding: 5px;
    cursor: pointer;
    font-size: 16px;
}

.history-item-actions button:hover {
    background: var(--color-warning);
}

.history-item:hover {
    background-color: var(--brand-secondary);
}

.history-item-name {
    color: var(--brand-primary);
    font-family: "Roboto-Medium", Helvetica;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-time {
    color: var(--color-text-secondary);
    font-family: "Roboto", Helvetica;
    font-size: 12px;
}

.history-item-description {
    display: block;
    color: #444;
    font-size: 12px;
    overflow: hidden;
    margin-top: 5px;
}

.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    font-weight: 500;
    gap: 6px;
}

.collapse-arrow {
    font-size: 14px;
    transition: transform 0.2s;
    display: inline-block;
    width: 18px;
    text-align: center;
}

.history-items-container.collapsed {
    display: none;
}

.suggestions-box {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    max-width: 200px;
    display: none;
}

.suggestion {
    padding: 6px 12px;
    cursor: pointer;
    font-family: 'Noto Sans Devanagari', sans-serif;
    font-size: 15px;
    white-space: nowrap;
}

.suggestion:hover {
    background: #f0f4ff;
    color: var(--brand-primary);
}

.main-content {
    transition: margin-left 0.3s cubic-bezier(.4,0,.2,1);
    margin-left: 0;
}

.main-content.shifted {
    margin-left: 300px; /* Match the sidebar width */
}

.bihar-police-logo-header {
    height: 28px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

.footer-bihar-police {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 44px;
    margin-top: 24px;
    padding: 0 16px;
    box-sizing: border-box;
    background: var(--brand-secondary);
    border-top: 2px solid var(--brand-primary);
    color: var(--brand-primary);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.bihar-police-logo-footer {
    height: 26px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

.footer-bihar-police span {
    line-height: 1;
    white-space: nowrap;
}

/* Help FAB — bottom-left so it clears the page pill */
.help-fab {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 25;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--color-border-medium);
    background: var(--brand-white);
    color: var(--color-text-muted);
    box-shadow: var(--shadow-medium);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.help-fab:hover {
    background: var(--color-hover-brand);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* ── Voice dictation FAB ── */
.dictation-fab {
    position: fixed;
    z-index: var(--z-dictation);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    touch-action: none;
    user-select: none;
}

.dictation-fab[data-edge="left"] {
    align-items: flex-start;
}

.dictation-fab[data-edge="right"] {
    align-items: flex-end;
}

.dictation-fab[hidden] {
    display: none !important;
}

.dictation-fab.is-dragging {
    opacity: 0.92;
    cursor: grabbing;
}

.dictation-interim {
    position: fixed;
    left: 50%;
    bottom: 72px;
    z-index: var(--z-dictation);
    max-width: min(420px, calc(100vw - 48px));
    padding: 8px 14px;
    background: rgba(1, 0, 128, 0.92);
    color: var(--brand-white);
    border-radius: 10px;
    font-family: 'Noto Sans Devanagari', 'Roboto', sans-serif;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: var(--shadow-popup);
    pointer-events: none;
    transform: translateX(-50%);
    text-align: center;
}

.dictation-interim[hidden] {
    display: none !important;
}

/* Mic is the only in-flow size; chips bloom outward via absolute positioning */
.dictation-cluster {
    position: relative;
    width: 52px;
    height: 52px;
}

.dictation-lang,
.dictation-end {
    position: absolute;
    top: 50%;
    z-index: 3;
    appearance: none;
    border: 1px solid var(--color-border-medium);
    background: var(--brand-white);
    color: var(--brand-primary);
    box-shadow: var(--shadow-medium);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.12s ease;
}

.dictation-lang {
    height: 28px;
    min-width: 36px;
    padding: 0 10px;
    border-radius: 999px;
    font-family: 'Noto Sans Devanagari', 'Roboto', sans-serif;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dictation-end {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--color-error);
}

.dictation-end[hidden] {
    display: none !important;
}

/* Right edge (default): bloom left from mic */
.dictation-fab[data-edge="right"] .dictation-lang,
.dictation-fab[data-edge="right"] .dictation-end {
    right: 60px;
    left: auto;
    transform: translateY(-50%) scale(0.75);
    transform-origin: right center;
}

.dictation-fab[data-edge="right"] .dictation-cluster:has(.dictation-end:not([hidden])) .dictation-lang {
    right: 100px;
}

/* Left edge: bloom right from mic */
.dictation-fab[data-edge="left"] .dictation-lang,
.dictation-fab[data-edge="left"] .dictation-end {
    left: 60px;
    right: auto;
    transform: translateY(-50%) scale(0.75);
    transform-origin: left center;
}

.dictation-fab[data-edge="left"] .dictation-cluster:has(.dictation-end:not([hidden])) .dictation-lang {
    left: 100px;
}

.dictation-fab:hover .dictation-lang,
.dictation-cluster.is-expanded .dictation-lang,
.dictation-cluster.is-expanded .dictation-end:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
}

.dictation-fab[data-edge="right"]:hover .dictation-lang,
.dictation-fab[data-edge="right"] .dictation-cluster.is-expanded .dictation-lang,
.dictation-fab[data-edge="right"] .dictation-cluster.is-expanded .dictation-end:not([hidden]) {
    transform: translateY(-50%) scale(1);
}

.dictation-fab[data-edge="left"]:hover .dictation-lang,
.dictation-fab[data-edge="left"] .dictation-cluster.is-expanded .dictation-lang,
.dictation-fab[data-edge="left"] .dictation-cluster.is-expanded .dictation-end:not([hidden]) {
    transform: translateY(-50%) scale(1);
}

.dictation-lang:hover,
.dictation-end:hover {
    background: var(--color-hover-brand);
}

.dictation-mic-wrap {
    position: relative;
    width: 52px;
    height: 52px;
}

.dictation-level {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--color-mic-live);
    opacity: 0;
    transform: scale(var(--dictation-level, 1));
    pointer-events: none;
    z-index: 0;
}

.dictation-fab.is-listening .dictation-level {
    animation: dictation-pulse 1.6s ease-out infinite;
}

.dictation-mode {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--brand-white);
    background: var(--color-mic-live);
    z-index: 2;
    pointer-events: none;
    box-shadow: var(--shadow-light);
    opacity: 0;
}

.dictation-fab.is-active .dictation-mode {
    opacity: 1;
}

.dictation-mode[data-mode="cloud"] {
    background: var(--color-mic-cloud);
}

.dictation-mic {
    position: relative;
    z-index: 1;
    appearance: none;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: var(--brand-primary);
    color: var(--brand-white);
    box-shadow: var(--shadow-popup);
    cursor: grab;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.15s ease, transform 0.15s ease;
}

.dictation-mic:hover {
    transform: scale(1.04);
}

.dictation-mic:active,
.dictation-fab.is-dragging .dictation-mic {
    cursor: grabbing;
}

.dictation-fab.is-listening .dictation-mic {
    background: var(--color-mic-live);
}

.dictation-fab.is-paused .dictation-mic {
    background: var(--color-mic-cloud);
}

@keyframes dictation-pulse {
    0% {
        opacity: 0.35;
        transform: scale(1);
    }
    70% {
        opacity: 0;
        transform: scale(1.55);
    }
    100% {
        opacity: 0;
        transform: scale(1.55);
    }
}

@media (prefers-reduced-motion: reduce) {
    .dictation-fab.is-listening .dictation-level {
        animation: none;
    }
    .dictation-lang,
    .dictation-end,
    .dictation-mic {
        transition: none;
    }
}

/* Onboarding / consent sheet */
.dictation-sheet {
    position: relative;
    border: none;
    border-radius: 16px;
    padding: 0;
    max-width: min(420px, calc(100vw - 32px));
    width: 100%;
    box-shadow: var(--shadow-popup);
    background: var(--brand-white);
    color: var(--color-text-primary);
    font-family: 'Noto Sans Devanagari', 'Roboto', sans-serif;
}

.dictation-sheet::backdrop {
    background: var(--shadow-overlay);
}

.dictation-sheet-close {
    position: absolute;
    top: 12px;
    right: 12px;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dictation-sheet-close:hover {
    background: var(--color-hover-brand);
    color: var(--brand-primary);
}

.dictation-sheet-body {
    padding: 28px 24px 24px;
    text-align: center;
}

.dictation-sheet-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--color-hover-brand);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.dictation-sheet-icon.is-warn {
    background: rgba(217, 131, 36, 0.12);
    color: var(--color-mic-cloud);
}

.dictation-sheet-icon.is-error {
    background: rgba(254, 1, 0, 0.08);
    color: var(--color-error);
}

.dictation-sheet-title {
    margin: 0 0 4px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-primary);
}

.dictation-sheet-sub {
    margin: 0 0 14px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.dictation-sheet-copy {
    margin: 0 0 10px;
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: left;
}

.dictation-sheet-copy.muted {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
}

.dictation-sheet-steps {
    text-align: left;
    margin: 0 0 12px;
    padding-left: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--color-text-primary);
}

.dictation-sheet-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 18px;
}

.dictation-sheet-primary,
.dictation-sheet-secondary {
    appearance: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.dictation-sheet-primary {
    border: none;
    background: var(--brand-primary);
    color: var(--brand-white);
}

.dictation-sheet-primary:hover {
    filter: brightness(1.08);
}

.dictation-sheet-secondary {
    border: 1px solid var(--color-border-medium);
    background: var(--brand-white);
    color: var(--color-text-secondary);
}

.dictation-sheet-secondary:hover {
    background: var(--color-hover-brand);
    color: var(--brand-primary);
}

.dictation-progress {
    height: 6px;
    border-radius: 999px;
    background: var(--color-border-light);
    overflow: hidden;
    margin: 16px 0 4px;
}

.dictation-progress-bar {
    height: 100%;
    width: 40%;
    border-radius: inherit;
    background: var(--brand-primary);
    animation: dictation-indeterminate 1.2s ease-in-out infinite;
}

@keyframes dictation-indeterminate {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(320%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .dictation-progress-bar {
        animation: none;
        width: 100%;
        opacity: 0.6;
    }
}

@media print {
    .modal-overlay {
        position: static;
        background: none;
    }
    .modal-content {
        box-shadow: none;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    .modal-header,
    .modal-footer,
    .close-btn,
    .footer-bihar-police,
    .header-frame,
    .sidebar,
    .switch-btn,
    .help-fab,
    .page-indicator,
    .dictation-fab,
    .dictation-interim,
    .dictation-sheet {
        display: none !important;
    }
    .modal-body {
        overflow: visible;
        border: none;
        padding: 0;
    }
}

/* Consolidated Diary Form Styles — see .diary-* rules near .editor-diary */