:root {
  --bg-primary: #0f172a;
  --bg-secondary: #020617;
  --border: #334155;
  --text-primary: #e5e7eb;
  --text-secondary: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
}

[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --border: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
}

[data-theme="light"] .container {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .icon-btn:hover {
  background: var(--accent);
  color: white;
}

[data-theme="light"] button.secondary {
  background: #e2e8f0;
  color: #0f172a;
}

[data-theme="light"] button.secondary:hover {
  background: #cbd5e1;
}

* {
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 20px;
  margin: 0;
}

.container {
  max-width: 560px;
  margin: auto;
  background: var(--bg-secondary);
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header h2 {
  margin: 0;
}

.icon-btn {
  width: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 20px;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

label { 
  display: block; 
  margin-top: 12px; 
  font-size: 14px;
  font-weight: 500;
}

input {
  width: 100%;
  padding: 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-group input {
  flex: 1;
}

.input-group .icon-btn {
  margin-top: 0;
  min-width: 45px;
}

button {
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s;
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

button.secondary { 
  background: var(--border);
  color: var(--text-primary);
}

button.secondary:hover {
  background: #475569;
}

button.small {
  font-size: 13px;
  padding: 8px;
}

.button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-group button {
  margin-top: 8px;
}

.output {
  margin-top: 15px;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  word-break: break-all;
  font-size: 16px;
  min-height: 24px;
}

.meter {
  height: 8px;
  background: var(--bg-primary);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 6px;
}

.meter div {
  height: 100%;
  transition: width 0.3s, background 0.3s;
}

small { 
  color: var(--text-secondary);
  font-size: 13px;
}

#copyBtn {
  background: var(--border);
  color: var(--text-primary);
  transition: background 0.3s;
}

#copyBtn.copied {
  background: #16a34a;
  color: white;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.check {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.check input {
  display: none;
}

.check span {
  position: relative;
  padding-left: 34px;
}

.check span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  transition: all 0.2s ease;
}

.check span::after {
  content: "✓";
  position: absolute;
  left: 4px;
  top: 40%;
  transform: translateY(-52%);
  font-size: 24px;
  color: white;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.check input:checked + span::before {
  background: var(--accent);
  border-color: var(--accent);
}

.check input:checked + span::after {
  opacity: 1;
}

.check:hover span::before {
  border-color: #60a5fa;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-secondary);
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h3 {
  margin-top: 0;
}

.modal-content canvas {
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  margin: 15px auto;
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* History */
.history-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.history-section h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  border-color: var(--accent);
  transform: translateX(4px);
}

.history-item-info {
  flex: 1;
}

.history-item-resource {
  font-weight: 500;
  font-size: 14px;
}

.history-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.history-item-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  margin: 0;
  width: auto;
  font-size: 18px;
}

.history-item-delete:hover {
  color: #dc2626;
  transform: scale(1.2);
}

/* Reminder */
.reminder {
  margin-top: 20px;
  padding: 12px;
  background: #fef3c7;
  color: #78350f;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  animation: slideUp 0.3s;
}

[data-theme="light"] .reminder {
  background: #fef3c7;
  color: #78350f;
}

.reminder button {
  background: #78350f;
  color: white;
  padding: 6px 12px;
  font-size: 12px;
  margin: 0;
  width: auto;
}

/* Scrollbar */
.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.modal-content button {
  margin: 5px;
  width: auto;
  min-width: 120px;
}
@media (max-width: 600px) {
  body {
    padding: 10px;
  }
  
  .container {
    padding: 20px;
  }
  
  .options {
    grid-template-columns: 1fr;
  }
  
  .button-group {
    grid-template-columns: 1fr;
  }
}