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

:root {
  --accent: #7a4cf2;
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-card: #1a1a1a;
  --text-primary: #e0e0e0;
  --text-secondary: #888888;
  --border: #2a2a2a;
  --search-bg: #141414;
}

[data-theme="light"] {
  --accent: #6fd4bb;
  --bg-primary: #f5f5f5;
  --bg-secondary: #eeeeee;
  --bg-card: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --border: #dddddd;
  --search-bg: #ffffff;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

/* Header */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  width: var(--logo-size, 36px);
  height: var(--logo-size, 36px);
  border-radius: 8px;
}

#site-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

[data-theme="dark"] .theme-icon-dark { display: inline; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: inline; }

/* Search */
#search-container {
  position: relative;
  margin-bottom: 1rem;
}

#search-input {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--search-bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

#search-input:focus {
  border-color: var(--accent);
}

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#search-results.hidden {
  display: none;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.15s;
}

.search-result:hover,
.search-result.active {
  background: var(--bg-secondary);
}

.search-result-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.search-result-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.search-result-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.search-result-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tabs */
#tabs-nav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-family: inherit;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Content / Groups */
#content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.group-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.group-title:hover {
  color: var(--text-primary);
}

.group-chevron {
  font-size: 0.6rem;
  transition: transform 0.2s;
  transform: rotate(90deg);
  display: inline-block;
}

.group.collapsed .group-chevron {
  transform: rotate(0deg);
}

.group-body {
  transition: max-height 0.25s ease, opacity 0.2s ease;
  overflow: hidden;
}

.group.collapsed .group-body {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
}

.group.collapsed .group-title {
  margin-bottom: 0;
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}

.link-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.15s;
}

.link-item:hover {
  background: var(--bg-secondary);
}

.link-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 4px;
}

.link-name {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Subgroups */
.subgroup {
  margin-bottom: 1rem;
}

.subgroup:last-child {
  margin-bottom: 0;
}

.subgroup-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}

/* Widget areas */
.widget-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#widget-area-bottom {
  justify-content: center;
  padding-top: 2rem;
}

.widget-clock {
  text-align: right;
}

.widget-clock-time {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.widget-clock-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.widget-greeting {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Weather widget */
.widget-weather {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.widget-windsock {
  width: 48px;
  height: 48px;
}

.widget-windsock svg {
  width: 100%;
  height: 100%;
}

.widget-weather-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.widget-weather-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.widget-weather-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.widget-weather-label {
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.widget-wind-info {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
  #app {
    padding: 1rem;
  }

  .links-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  #header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}
