
:root {
  /* Light theme (default) */
  --bg: #ffffff;
  --panel: #f3f4f6;
  --muted: #6b7280;
  --accent: #dc2626;
  --ring: #e5e7eb;
  --text: #111827;
  
  --chip-size: 22px;
  --item-gap-left: 46px;
  
  color-scheme: light;
}

:root[data-theme-resolved="dark"] {
  --bg: #0f1115;
  --panel: #171a21;
  --muted: #8b90a0;
  --accent: #c00;
  --ring: #262a35;
  --text: #f2f4f8;
  
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.action-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--ring);
  background: var(--panel);
  cursor: pointer;
  user-select: none;
  padding: 0;
}

.action-btn:hover {
  background: rgba(128, 128, 128, 0.1);
  color: var(--text);
}

.action-btn svg {
  width: 20px;
  height: 20px;
}

h1 {
  margin: 0;
  text-align: center;
  font-weight: 650;
  letter-spacing: .2px;
  font-size: clamp(18px, 2.4vw, 28px);
  flex: 1;
}

main {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 0;
}

/* Item list sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--ring);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--ring);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--ring);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-close-btn:hover {
  background: rgba(128, 128, 128, 0.1);
  color: var(--text);
}

.item-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.item-item {
  padding: 12px 14px;
  margin-bottom: 6px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.item-item:hover {
  background: rgba(128, 128, 128, 0.08);
}

.item-item:hover .delete-item-btn {
  opacity: 1;
}

.item-item.active {
  background: rgba(192, 0, 0, 0.1);
  border-color: var(--accent);
}

/* Adjust active state for light mode if needed via CSS variable if desired, 
   but transparent red works decently on both. */

.item-item-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-item-count {
  font-size: 12px;
  color: var(--muted);
}

.item-item-actions {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
  margin-top:14px;
}

.item-item.active .item-item-actions,
.item-item:hover .item-item-actions {
  opacity: 1;
}

.share-item-btn,
.delete-item-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--ring);
  background: var(--bg);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease;
}

.share-item-btn {
  color: #3b82f6;
}

.share-item-btn:hover {
  background: #3b82f6;
  color: #fff;
}

.delete-item-btn {
  color: #ef4444;
}

.delete-item-btn:hover {
  background: #ef4444;
  color: #fff;
}

.share-item-btn svg,
.delete-item-btn svg {
  width: 16px;
  height: 16px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--ring);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.new-item-btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--ring);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease;
}

.new-item-btn:hover {
  background: var(--panel);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 45;
  display: none;
}

.sidebar-overlay.show {
  display: block;
}

/* Share dialog */
dialog#shareDialog {
  position: relative;
  border: 1px solid var(--ring);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  width: min(92vw, 500px);
  padding: 20px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, .55);
}

.share-dialog-header {
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 16px;
}

.share-url-container {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.share-url-input {
  flex: 1;
  border: 1px solid var(--ring);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  outline: none;
}

.copy-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--ring);
  background: #3b82f6;
  color: #fff;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s ease;
}

.copy-btn:hover {
  background: #2563eb;
}

.copy-btn.copied {
  background: #22c55e;
}

.share-dialog-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Share box footer */
.share-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  border-top: 1px solid var(--ring);
  padding: 12px 16px;
  display: flex;
  justify-content: center;
  z-index: 10;
}

.share-box {
  width: 100%;
  max-width: min(92vmin, 840px);
  display: flex;
  align-items: center;
  gap: 12px;
}

.share-box-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.share-box-container {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.share-box-input {
  flex: 1;
  border: 1px solid var(--ring);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  outline: none;
}

.share-box-copy-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--ring);
  background: #3b82f6;
  color: #fff;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.share-box-copy-btn:hover {
  background: #2563eb;
}

.share-box-copy-btn.copied {
  background: #22c55e;
}

.download-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--ring);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.download-btn:hover {
  background: var(--ring);
}

.file-dropzone {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  font-weight: 600;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  pointer-events: none;
}

.dropzone-content svg {
  width: 64px;
  height: 64px;
  stroke-width: 1.5;
}
