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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

h1 {
    color: #333;
    font-size: 28px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-secondary {
    background: #718096;
    color: white;
    font-size: 12px;
    padding: 8px 16px;
}

.btn-secondary:hover {
    background: #4a5568;
}

.settings-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow: hidden;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    user-select: none;
}

.settings-header:hover {
    background: rgba(102, 126, 234, 0.05);
}

.settings-header span {
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-toggle {
    background: none;
    border: none;
    color: #667eea;
    font-size: 12px;
    cursor: pointer;
    transition: transform 0.3s ease;
    padding: 5px;
}

.settings-toggle.expanded {
    transform: rotate(180deg);
}

.settings-content {
    padding: 0 20px;
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.settings-content.collapsed {
    max-height: 0;
    padding: 0 20px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 0;
    cursor: pointer;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.setting-item span {
    font-size: 14px;
    color: #333;
}

.layout-select {
    padding: 6px 12px;
    border-radius: 5px;
    border: 1px solid #cbd5e0;
    background: white;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.layout-select:hover {
    border-color: #667eea;
}

.layout-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

body.compact-layout header {
    padding: 12px 20px;
    margin-bottom: 12px;
}

body.compact-layout h1 {
    font-size: 20px;
}

body.compact-layout .btn {
    padding: 6px 12px;
    font-size: 12px;
}

body.compact-layout .btn-secondary {
    padding: 5px 10px;
    font-size: 11px;
}

body.compact-layout .settings-panel {
    margin-bottom: 12px;
}

body.compact-layout .settings-header {
    padding: 10px 15px;
}

body.compact-layout .settings-header span {
    font-size: 12px;
}

body.compact-layout .settings-toggle {
    font-size: 10px;
}

body.compact-layout .settings-content {
    max-height: 120px;
}

body.compact-layout .settings-content.collapsed {
    max-height: 0;
}

body.compact-layout .setting-item {
    padding: 10px 0;
}

body.compact-layout .setting-item span {
    font-size: 12px;
}

body.compact-layout .setting-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

body.compact-layout .layout-select {
    padding: 4px 8px;
    font-size: 12px;
}

body.compact-layout .stopwatch-card {
    padding: 12px 16px;
    gap: 8px;
}

body.compact-layout .time-display {
    font-size: 32px;
}

body.compact-layout .stopwatch-name {
    font-size: 14px;
}

body.compact-layout .delete-btn {
    font-size: 16px;
}

body.compact-layout .controls {
    gap: 6px;
}

body.compact-layout .controls .btn {
    padding: 6px 12px;
    font-size: 12px;
}

body.compact-layout .session-history {
    margin-top: 12px;
}

body.compact-layout .history-header h3 {
    font-size: 11px;
}

body.compact-layout .toggle-history {
    font-size: 10px;
}

body.compact-layout .history-item {
    padding: 6px 8px;
    margin-bottom: 4px;
    font-size: 11px;
}

body.compact-layout .history-item-duration {
    margin-bottom: 2px;
}

body.compact-layout .history-item-times {
    font-size: 10px;
}

body.compact-layout .stopwatch-container {
    gap: 12px;
}

body.compact-layout .group-container {
    padding: 12px;
    margin-bottom: 20px;
}

body.compact-layout .group-header {
    padding: 10px 15px;
    margin-bottom: 10px;
}

body.compact-layout .group-name {
    font-size: 16px;
}

body.compact-layout .group-stopwatches {
    gap: 12px;
    min-height: 60px;
    padding: 8px;
}

body.compact-layout .group-stopwatches.collapsed {
    max-height: 0;
    min-height: 0;
    padding: 0;
    margin-bottom: 0;
}

body.compact-layout .ungrouped-section {
    padding: 12px;
    margin-top: 20px;
}

body.compact-layout .ungrouped-header {
    font-size: 14px;
    margin-bottom: 10px;
}

body.compact-layout .drop-placeholder {
    min-height: 60px;
    padding: 15px;
}

.stopwatch-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}

.stopwatch-card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease, border 0.3s ease;
    cursor: grab;
    min-width: fit-content;
    border: 2px solid transparent;
}

.stopwatch-card:active {
    cursor: grabbing;
}

.stopwatch-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.stopwatch-card:hover {
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
}

.stopwatch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.stopwatch-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 5px;
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s ease;
}

.stopwatch-name:hover,
.stopwatch-name:focus {
    border-bottom-color: #667eea;
    outline: none;
}

.delete-btn {
    background: none;
    border: none;
    color: #f56565;
    font-size: 20px;
    cursor: pointer;
    padding: 5px 10px;
}

.delete-btn:hover {
    color: #e53e3e;
}

.time-display {
    font-size: 48px;
    font-weight: 700;
    text-align: center;
    color: #667eea;
    margin: 20px 0;
    font-variant-numeric: tabular-nums;
}

.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.controls .btn {
    flex: 1;
}

select.btn {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.session-history {
    margin-top: 20px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-header h3 {
    font-size: 14px;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toggle-history {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.toggle-history:hover {
    text-decoration: underline;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid #e2e8f0;
    padding-top: 10px;
}

.history-list.collapsed {
    display: none;
}

.history-item {
    padding: 10px;
    margin-bottom: 8px;
    background: #f7fafc;
    border-radius: 5px;
    font-size: 13px;
}

.history-item-duration {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 4px;
}

.history-item-times {
    color: #718096;
    font-size: 12px;
}

.no-history {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 20px;
}

@keyframes subtle-glow {
    0% {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 0 20px rgba(72, 187, 120, 0.3);
    }
    100% {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
}

.stopwatch-card.running {
    border: 2px solid #48bb78;
    animation: subtle-glow 0.6s ease-out;
}

.stopwatch-card.running .time-display {
    color: #48bb78;
}

.group-container {
    margin-bottom: 30px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.group-container.drag-over {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.group-title-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.group-collapse-btn {
    background: none;
    border: none;
    color: #667eea;
    font-size: 14px;
    cursor: pointer;
    padding: 5px 10px;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
}

.group-collapse-btn:hover {
    color: #5568d3;
}

.group-name {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 5px;
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s ease;
    width: 100%;
}

.group-name:hover,
.group-name:focus {
    border-bottom-color: #667eea;
    outline: none;
}

.group-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.group-stopwatches {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 0;
    max-height: 10000px;
    overflow: hidden;
    transition: max-height 0.3s ease, margin-bottom 0.3s ease;
    align-items: flex-start;
    min-height: 100px;
    padding: 10px;
    border-radius: 8px;
}

.group-stopwatches.drag-over {
    background: rgba(102, 126, 234, 0.08);
    border: 2px dashed #667eea;
}

.group-stopwatches.collapsed {
    max-height: 0;
    min-height: 0;
    padding: 0;
    margin-bottom: 0;
    overflow: hidden;
    border: none;
}

.ungrouped-section {
    margin-top: 30px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.ungrouped-section.drag-over {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
}

.ungrouped-header {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 15px;
    padding: 0 5px;
}

.drop-placeholder {
    border: 2px dashed #667eea;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    color: #667eea;
    font-weight: 600;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}
